Skip to content Accesskey=4Skip to sub-navigation Accesskey=3View our Accessibility Options MIT Information Systems Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

On This Page

[Help]

  

Quick Links

Top Level

Related Links

Ask OLC a question

Athena Consulting Homepage

Helpdesk Stock Answers (for Mac/PC questions)


DEBUGGING Matlab .m files

MATLAB provides a debugging facility that allows you to stop at
specific points in your .m files, examine the workspace and
step through execution of your code. For example, while developing
a function ops.m, an error occurs. Matlab will give an error message
similar to:

   ??? Error using ==> ones
   Too many input arguments.

   Error in ==> /afs/athena.mit.edu/software/vizdev/matlab/ops.m
   On line 10  ==> A = ones(n,n,n);
  

The first 2 lines explain the error, and the next two give the
location of the error. To use the debugging facility to determine
what is happening, you start with the "dbstop" command.  This command
provides a number of options for stopping execution of a Matlab
function. A particularly useful option is

         >> dbstop if error

This causes a stop in any M-file function causing a  run-time error.
Then just run the Matlab command. In this case

         >> ops(5)

Execution will stop at the point where the error occurs, and you will get the
Matlab prompt back so that you can examine variables or step through
execution from that point. In the example:
         >> ops(5)
        10  A = ones(n,n,n);
        K>>

The command "dbstep" allows you to step through execution one line
at a time. You can continue execution with the "dbcont" command.
To exit  debug mode, type "dbquit".

For more information, see the Matlab help for the following topics:

     debug, dbstop, dbclear, dbcont, dbdown, dbstack, dbstatus 
     dbstep, dbtype, dbup, dbquit  


last updated: 7/13/95

MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.