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
1 Answer
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!
2 Comments
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)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.
stepinstead ofstep in! mathworks.com/help/matlab/matlab_prog/…MyClass(angle(H), param2);step out?dbstep in. It then inspects the current stack withdbstackand if the current function resides intoolboxdir, you step out:dbstep out