Development Environment | ![]() ![]() |
Running an M-File
After setting breakpoints, run the M-file from the Command Window or the Editor/Debugger.
For the example, run collatzplot
for the simple input value, 3, by typing in the Command Window
collatzplot(3)
Running an M-File from the Editor/Debugger. You can run a script, that is, an M-file that doesn't require an input argument, directory from the Editor/Debugger by clicking the run button on the toolbar. You can also run it by selecting Run or Save and Run (if the file has unsaved changes) from the Debug menu. The example,
collatzplot
, requires an input argument and therefore runs only from the Command Window and not from the Editor/Debugger.
Running the M-file results in the following:
K>
>, indicating that MATLAB is in debug mode.If you use debugging functions and have the Debugger options preference for Command Window debugging checked, the line at which you are paused is displayed in the Command Window. For the example, it would show
10 plot_seq = collatz(m);
dbstack
to view the current call stack. The call stack includes subfunctions as well as called functions.![]() | Setting Breakpoints | Stepping Through an M-File | ![]() |