Be the first to rate this file! 12 downloads (last 30 days) File Size: 12.09 MB File ID: #22881

Setting break points to find errors in for loops

by Doug Hull

 

03 Feb 2009

Code covered by BSD License  

Three minute video shows a debugging session for a tricky error

Download Now | Watch this File

File Information
Description

clear
num = [1 1 1 1 1 1 1];
den = [1 2 3 0 5 6 7];

for i = 1: numel(den)
    if den(i) == 0
        a(i) = 1
    else
        a(i) = num(i)/den(i)
    end
end

plot(a,'o-')
                    
The above code does not behave as expected. The values in the middle of the vector are zeroed out. This debugging sesion figures out why this happens.
                    
See more videos without downloading here: http://blogs.mathworks.com/videos/category/video/

MATLAB release MATLAB 7.7 (R2008b)
Zip File Content  
HTML Files Video from http://blogs.mathworks.com/pick
Other Files
141 Basics debuging example.flv,
141 Basics debuging example.js,
141 Basics debuging example_config.xml,
141 Basics debuging example_controller.swf,
141 Basics debuging example_nofp_bg.gif,
141 Basics debuging example_preload.swf,
FlashTemplate.css,
mCode/141 Basics debuging example.camrec,
mCode/main.asv,
mCode/main.m,
ProductionInfo.xml,
swfobject.js
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
video Doug Hull 03 Feb 2009 16:39:01
tutorial Doug Hull 03 Feb 2009 16:39:01
debug Doug Hull 03 Feb 2009 16:39:01
breakpoint Doug Hull 03 Feb 2009 16:39:01
dbcont Doug Hull 03 Feb 2009 16:39:01
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com