0

I have a user written Matlab code which consists of multiple files. I read files one by one. If I need to check the correctness of a single file which implements a function, call it Func, then how to I check the specific file for errors? How do I apply break points so that I can see what the function is doing, because the function as defined in the file consists of variables, while I need to check part of the function using specific values.

1 Answer 1

4

I believe you are asking how to work with breakpoints.

The easiest way to do this, is to click just left of your code. A red dot will appear to indicate that you set a breakpoint. I found an example image:

enter image description here

If your code reaches the breakpoint, it will stop there and you can evaluate all variables that exist at the time (most even with mouseover), as well as update them to represent the situation that you are interested in.


If you want to evaluate multiple lines, you can stop before the relevant section (by putting a breakpoint there) and then hit f10 to evaluate a line. Make sure to check the documentation for more options.

Sign up to request clarification or add additional context in comments.

9 Comments

Also consider adding to this question Conditional Breakpoints" stackoverflow.com/questions/34027454/…
@AnderBiguri That is definitely usefull in general (like several other things), but as one you can simply change the values of variables whilst in debugging mode, I think it is not needed for this particular question. -- Have added the option to update variables in the answer.
Yes, yes, you are rigth. Just to add as "general knowledge thing" ;). Good answer btw
@user3676846 The easiest way to do this, is to put the breakpoint inside the relevant function. If you can't find the function (and thus can't put in the breakpoint) you should be able to put the breakpoint on the line of the function call and then 'step into' it (f11 in matlab). --I am unfortunately not sure how close to Matlab octave really is on this aspect. -- Alternately you should be able to use dbstop.
@user3676846 Exactly, if it behaves like matlab you will be in the workspace, where the breakpoint is hit.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.