2

When I set a break point for debugging, the cursor "penetrates" through function angle and checks the corresponding code too. How can I force the cursor to only scan my code?
The weird thing is it doesn't do so for the functions sum or abs
Thanks

11
  • 1
    step instead of step in! mathworks.com/help/matlab/matlab_prog/… Commented Jun 26, 2013 at 15:18
  • 1
    @Dan that's not exactly a good enough solution. Sometimes you want to step into code that uses these files, i.e. MyClass(angle(H), param2); Commented Jun 26, 2013 at 15:20
  • 1
    @KronoS then use step out ? Commented Jun 26, 2013 at 15:21
  • @Dan again, it's frustrating to have these classes/scripts automatically debugged. Instead of taking the extra 'steps' and having to figure out where the heck I am instead of the file that I thought I was going to be in, it'd be nice if we could skip that all together. Commented Jun 26, 2013 at 15:23
  • 3
    I wouldnt use it myself, but perhaps you can hack something together by writing a "shortuct" in the IDE which starts by stepping into the code dbstep in. It then inspects the current stack with dbstack and if the current function resides in toolboxdir, you step out: dbstep out Commented Jun 26, 2013 at 15:31

1 Answer 1

3

The answer as to why commands like abs and sum are automatically skipped is because they are compiled, proprietary MATLAB functions that don't actually have any readable MATLAB code with them. If you do edit('angle.m') (maybe without the m, I forget) you will see the code (as expected). Now do the same for sum, and you will notice there is no MATLAB code there, just comments. The core MATLAB functions, like sum, but also like clc and close are all core embedded functions so we can't see the code.

As was mentioned earlier in the comments, the debugger has tools that allow you to just step instead of step in, and if you are stepped in one part, you can always step out to the function calling the one you are currently looking at. Also, to skip a couple lines of code at a time, the "run to cursor" can be incredibly useful!

More details can be found in the docs

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

2 Comments

fyi they are called builtin functions. You can use: which -all funcname to see what type it is (the -all arguments returns all overloaded versions. You could be more specific with: which sum(1) that way MATLAB shows the one for that specific syntax)
The function exist can also be useful if you just want differentiate between builtin functions and M-files. For example, the following anonymous functions might be useful isbuiltin=@(s)exist(s,'builtin')==5; or ismfile=@(s)exist(s,'file')==2;. Note that the second one won't detect mex files or p-files, etc., but exist (which too) can check for those as well.

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.