I (unfortunately) have a MATLAB project with two files, main.m and function.m. I spent my time editing function.m, which is called several times from main.m. When I press F5 on the keyboard, it runs the current file (function.m) so i need to keep changing back to main.m to run the projec开发者_如何学编程t, which is irritating. I am used to eclipse that will run the last launched.
Is there a way to effect that behaviour in MATLAB?
If any potential employers are reading this, please note that I am forced to use this program (which charges customers for access to thread-safe primitives) against my will.
Choose "Edit Run Configurations for function.m" in the run menu and write your custom line (main). See attached image.
If you're okay with clicking a button instead of hitting F5, you could make a "Run main" button in the shortcuts toolbar. In the main Matlab window, right-click the menu and turn on the Shortcuts toolbar if it's not on already. Right-click the shortcut toolbar, "new shortcut", put "Run main" in the label, and enter "main()" for the callback. This will work regardless of what file you're editing, and you could set up additional shortcuts for alternate run configurations if you get to that point.
I don't think you can define key bindings for these shortcuts. But if you really want it, Yair Altman's Undocumented Matlab site has a hack for adding arbitrary user defined key bindings that could probably be used here.
You could separate the windows into two external edit windows and use Alt + Tab
to switch and then F5
?
Just type main
at the command-line? And from then on, press the up key and hit enter?
精彩评论