Mike on the MATLAB Desktop
January 9th, 2012
Update to Running files from the Editor
Another R2011b change was recently discussed in a MATLAB Answers question. This change is when you use the run button in the MATLAB editor, the name of the script/function will be displayed in the Command Window.
Here is a visual example of that change:
From a MATLAB interpreter/workspace view there is no change in behavior. In previous versions, when you pressed the run button, that file’s active Run Configuration would evaluated in the base workspace. If you had not created or modified the run configuration, this would the same as typing the file’s name at the command prompt (assuming that the file was top on the Path). The change in R2011b is that we now show the file name in the Command Window and History as if you had typed it at the prompt and pressed Enter.
We made this change for clarity and consistency. What we want is for you to have a record of what was evaluated and be able to understand why the workspace is in its current state. This way if a script updates some variables, you’ll know what was run to cause those updates.
This does get a little more confusing if you have a run configuration, as the file name is displayed before the run configuration is evaluated, so the recorded output might not be the same as if you just ran the file directly from the command line.
Unfortunately, for some editor-centric workflows, this may decrease readability, as the original Answers poster found. Fortunately our own Scott answered with a workaround:
As a workaround, you could use the “Evaluate entire file” button on the second row of the editor toolbar (along with the other buttons for evaluating one cell at a time). If this button doesn’t appear, you can right-click on the toolbar to customize it and add the button back.
You can also assign a keyboard shortcut to the “Evaluate Entire File” action from File -> Preferences -> Keybaord -> Shortcuts. You can even reassign F5 to this action from its default “Run or Continue Execution.”
By
Michael Katz
Mike is a developer on the MATLAB Mobile team. When not describing himself in the third person, biking, homebrewing, or rooting for the home team, he's busy trying to make the world a better place for programming.
14:43 UTC |
Posted in Command Window, Editor |
Permalink |
2 Comments »
You can follow any responses to this entry through the RSS 2.0 feed.
You can skip to the end and leave a response. Pinging is currently not allowed.
Leave a Reply
|
If you are going for consistency/clarity, this same behavior should probably occur with shortcuts. I use custom shortcuts extensively, but nothing shows up in the Command Window or Command History when I click on my shortcut icons even though MATLAB executes the code snippets contained in the shortcuts in a similar manner as run configurations.
@Joseph,
That’s an excellent suggestion. I’ll let the team know.