How to execute an M- file line by line in Octave?

2.8k Views Asked by At

I don't have Matlab installed in my computer, but found I can use Octave in my Ubuntu machine that I installed long time ago. The Octave version on my CentOs machine is too low to run the program.

In VOC2012 devtools, I see example_classifier.m program which I can run by entering octave in the shell and typing example_classifier in the Octave shell. I can see the result files and graphs coming up.

But I need to analyze several M-file programs. Being able to analyze it line by line using debugger is crucial for an efficient work.

How can I use Octave to debug/analyze the code graphically? (I mean I want to use next, step-in, finish kind of commands inside the programs like I do in ddd with gdb).

2

There are 2 best solutions below

2
On BEST ANSWER

You can access the Octave debugger from the command line in the same way as you can access the MATLAB debugger:

  • dbstop defines a breakpoint. This can be used any time, Octave will enter debug mode when the breakpoint is hit.

    For example, dbstop myfunction will create a breakpoint at the beginning of the function myfunction, executing the function will immediately start the debugging at the top of that file.

  • dbstep executes the next line. You can also do dbstep in.

  • While in the debugger, you can examine variables in the function’s workspace just like you would in the base workspace under normal operation: type the name of a variable to see its value, use plot or any other command, etc.

See the documentation for a full list of debug commands.

0
On

I found I can just type
octave --force-gui
and open the program (example_classifier.m)
and in the editor pane (one of right side panes, you ca select at bottom right),
press the 'run' button (green triangular shape).
you can set break-points, single-step, and so on. (you can see the buttons.)

enter image description here