Reputation: 57
I want to run my program in debug mode using 'Step', 'Step In', 'Step Out' etc. But the buttons or icons are shadowed or disabled. So, how can I enter into debug mode?Please help me out.
Upvotes: 3
Views: 21033
Reputation: 1505
The standard debug type options of step in, step out, run to cursor etc only appear (on the Editor tab) once your running script has hit its first breakpoint.
To set a breakpoint, left-click in the left hand margin of the editor window for your script (just to the right hand of the line numbers (if you have them showing)).
The press F5
to start running your script, it will then stop at the first break point and then the other options will become available. There are tool tips for these options if you mouseover them - eg F10
to execute the next line,...
Upvotes: 0
Reputation: 11
Set a breakpoint at any line where you want to start stepping through the script. Run the script and the menu expands with all of the normal debugging step functions. Works well, but NOT intuitive, lacks the ability to step to the first line of code. If it is a small script just put the breakpoint at the first line of code and you can step through the entire thing if you want
Upvotes: 0
Reputation: 3994
There is no explicit debug mode in MATLAB. The reason for this is simply that a MATLAB script is interpreted, not compiled and also the fact that when your code finishes executing, the current data objects are saved in your workspace
unless you clear it explicitly.
Thus, to debug a MATLAB program, you simply need to run your code (with breakpoints
as found necessary) and check your data elements when the flow of execution breaks or terminates.
Upvotes: 5
Reputation: 15441
Do you have any breakpoints?
There's no debug mode in Matlab, you should have a breakpoint in some place and simply execute your code, the execution will stop at the breakpoint.
Upvotes: 5
Reputation: 7213
You need execution to break at some point in order to debug it. The simplest way is to add a keyboard
command at the point you would like to debug. When the line is reached, execution will stop and you will be able to inspect variables and step through your code. You may also want to use the command dbstop if error
which enters debug mode when an error is encountered, allowing you to inspect the state which caused the error.
Upvotes: 13