| Development Environment | ![]() |
This section introduces general techniques for finding errors, and then illustrates MATLAB debugger features found in the Editor/Debugger and equivalent debugging functions using a simple example. It includes these topics:
In addition to the Debugger and debugging functions, the Profiler included with MATLAB can be a useful tool to help you improve performance and detect problems in your M-files. For details, see Measuring Performance in the Programming and Data Types section of the MATLAB documentation.
Debugging is the process by which you isolate and fix problems with your code. Debugging helps to correct two kinds of errors:
pcode function to check for syntax errors in your M-file without running the M-file.
Usually, it is easy to find syntax errors based on MATLAB error messages. Run-time errors are more difficult to track down because the function's local workspace is lost when the error forces a return to the MATLAB base workspace. Use the following techniques to isolate the causes of run-time errors:
keyboard statements to the M-file. Keyboard statements stop M-file execution at the point where they appear and allow you to examine and change the function's local workspace. This mode is indicated by a special prompt:
depfun function to see the dependent functions.
The remainder of this section on debugging M-files describes the use of the Editor/Debugger and debugging functions using an example.
| Closing M-Files | Debugging Example--The Collatz Problem | ![]() |
Learn more about the latest releases of MathWorks products: |
| © 1994-2009 The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |