DOC PREVIEW
Duke CPS 111 - Debugging M-Files

This preview shows page 1-2-3-4-5 out of 14 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 14 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Debugging M-FilesSteve GuFeb 08, 2008Outline• What’s Debugging?• Types of Errors• Finding Errors• Debugging Example• Using Debugging FeaturesWhat’s Debugging?• Debugging is the process by which you can– Recognize a bug exists– Isolate source of bug– Identify cause of bug– Determine fix for bugTypes of Errors• Syntax Errors– Misspelling– Omitting parenthesis– MATLAB detects most syntax error and display error message in the command window• Run-time Errors– Modify the wrong variables– Perform a calculation incorrectly– Apparent when an M-file produces unexpected resultFind Errors• For syntax errors– Easy– MATLAB’s error messages• For Run-time errors– More difficult– Some useful techniques:• Remove ;• Add keyboard statements  K>> type return• Run M-file as a script• Use the ‘depfun’: e.g,list = depfun('binomial','-toponly');• Use the MATLAB Editor/Debugger or debugging functionsDebugging Example –Binomial.mUsing Debugging Features• Preparing for Debugging• Setting Breakpoints• Running an M-File with Breakpoints• Stepping through an M-File• Examining Values• Correcting Problems and Ending DebuggingPreparing for Debugging• Open the file – To use the Editor/Debugger• Save changesSetting Breakpoint• Setting Breakpoints Using the Editor– Set/Clear Breakpoint• Function Equivalent– dbstop in binomial at 14– Some Useful related functions• dbtype :Lists the M-file code• dbstatus :Lists breakpointsRunning an M-File with Breakpoints• Run M-file from command window or Editor• K>> -------MATLAB is in debug mode• The program is paused at the first breakpoint• The function displayed in the Stack changes to reflect the current functionStepping Through an M-FileExamining Values• Viewing Datatips in the Editor/Debugger• Viewing Values in the Array EditorViewing Values in Array EditorEnding Debugging• Quit Debugging• Clear all the breakpoints in the file• Make changes to the M-file• Save


View Full Document

Duke CPS 111 - Debugging M-Files

Download Debugging M-Files
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Debugging M-Files and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Debugging M-Files 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?