I said I would return in a week or so to talk about my experiences with using Matlab without a GUI in part 1/2 of this series. I also said I would get back with a report on how debugging works in a command line environment because it could be pretty important for a lot of us. But it seems Matlab has a pretty good setup to debug using the command line. This is just awesome and I am so happy.
With the following commands, you will be well setup to do some basic debugging. You can refer the help docs for your specific needs. This will give you a quick review of what you can do.
Set breakpoints at different places in the script using
dbstop. Mention the script name and the line number where you need to stop, using the following line of code on the command line.
dbstop in scriptname at linenumber
Look at all the places you have used a breakpoint using,
dbstatus. Just type in dbstatus in the command line and it will let you know.
When you are running the program, it would stop at the places where you have added breakpoints. When you are done analyzing your variables and what not, you can type in
dbcont to continue execution until it encounters the next breakpoint, or the end of the program.
You can use
dbstep to step one line at a time just like how you would with the GUI. You can also say something like
dbstep 5 to step through five lines of code.
Remove breakpoints in a line or, all of it in a file or, all of it in all files using
dbclear all will clear all of it in all places.
dbclear in script/filename will clear all breakpoints in a file. You can also add line number to remove something specific from a specific place.
dbquit to exit debugging mode.
For more interesting ways to debug, take a look at the help files. They have a load of information along with examples. You can use some of these commands with an if statement. Like for example, adding a break point when some condition is satisfied. This could be very useful. A lot of actual debugging does happen this way when you are working with a lot of code. Happy debugging.
It has not been one week yet. So I named this post 1.5/2. You can only really get a good picture of things over time. So it is not just a sensation but rather the actual fact. I will be back again in a week or so with my conclusions.