Octave set break point in a class function - class

How do I set a break point in an Octave class function when the class is implemented in a single m file?
Octave documentation https://www.gnu.org/software/octave/doc/interpreter/Breakpoints.html
briefly mentions:
Breakpoints in class methods are also supported (e.g., dbstop ("#class/method")).
However, my classdef file is a single m file directly sitting in my work dir. How do I set a break point in this case? I tried to do it in Octave 4.0.0 GUI, and in command window, use dbstop with various arguments I can imagine. But none worked. In Matlab, it is as simple as a click in the GUI editor.

Short answer: it does not work.
You are right, this should be possible, but it does not work due to a bug in Octave. The bug is already reported as #45404 on the Octave bug tracker.

Related

How to see the Matlab code behind a Matlab function

There is a function in Matlab called copulafit. How can I see the code that underlies this function? Many numpy and scipy functions for Python are readily open source on Github, but I can't find Matlab functions on Github for some reason
If you have MATLAB installed you can either highlight the function name then secondary/right-click and select Open "copulafit" or alternatively type open copulafit in the command window. Yeah, I believe MATLAB isn't open source as of this posting time/date. Possibly why the reason for the lack of GitHub resources. Octave might be something that might be interesting to look into.

Octave's equivalent to Matlab's which('filename', '-all')

In Matlab, which('filename', '-all') returns all the files with the given 'filename' in the Matlab path, but Octave only returns the first one (not the shadowed ones). Is there an easy way get the equivalent in Octave?
this is a longstanding feature request for Octave that as of this post has not yet been resolved. See Bug #32973 and Bug #32088. The latter link appears to have a workaround patch and function attached that never quite made it into the main codebase.
UPDATE 16 Nov 22: while the bug has not been fixed, rather than silently fail Octave v8 will now provide a warning to the user that the option is not yet implemented and only the first result will be returned.

How to locate where a built-in function is defined?

In MATLAB, there are roughly 3 ways to define functions: non-comment-only .m files, .p files, and compiled code (e.g. DLL, MEX).
Knowing where a function is defined could be helpful in several cases, such as when a breaking change was introduced to some function outside our control, and we'd like to try to revert to an old version in the hopes of getting our code working again; or when trying to reverse-engineering some undisclosed algorithm.
The which function is usually very good at identifying function definitions and their locations (which works for .m, .p and MEX), but isn't very useful when it comes to shared library functions, where (at best) it points to a comment-only documentation file:
>> which _mcheck
built-in (undocumented)
>> which svd
built-in (D:\Program Files\MATLAB\R2019a\toolbox\matlab\matfun\svd)
If so, assuming a function found within a shared library is called during the execution of my code, how can I locate the specific file (DLL) that contains it?
It turns out that dbstop can be used for this. For example:
>> which svd
built-in (D:\Program Files\MATLAB\R2019a\toolbox\matlab\matfun\svd)
>> dbstop svd
Warning: Entering debug mode is only supported within running MATLAB code files.
Warning: MATLAB debugger can only stop in MATLAB code files, and "libmwmathlinalg>svd" is not a MATLAB code file.
Instead, the debugger will stop at the point right before "libmwmathlinalg>svd" is called.
From there's it's just a matter of finding a file called libmwmathlinalg (with the relevant extension) - which isn't a difficult task if your drive is indexed.

Elusive MATLAB built-in function

I am trying to read the following internal MATLAB function:
>>which visionInitializeAndExpandCheckerboard
built-in (C:\Program Files\MATLAB\R2015a\toolbox\vision\vision\visionInitializeAndExpandCheckerboard)
But it appears to be hidden away! And very well hidden.
None of the following methods to access it have worked:
Highlighting the name and pressing Ctrl+D.
Typing "edit visionInitializeAndExpandCheckerboard" in the command line.
Searching for the file in Matlab's own FindFiles.
Searching for the file on the disk.
Trying to Step Into the function in debug mode (I just get the output as if I had requested Step Out instead).
Btw, the reason I am looking into this is that the parent function detectCheckerboardPoints has seriously declined in performance from R2015a to R2016b and I am trying to figure out why.
The internal function is compiled native code, so you will not be able to see its source. If you see a performance degradation, you should call Mathworks tech support and complain. If it is something they can fix, they will send you a patch, and fix it in the next release.

How to change the MATLAB path back to the default?

I was trying to add a toolbox in MATLAB and instead of calling addpath('path'), I called path('path').
Now I'm getting a lot of errors, like
if I initialize a variable, I get
Error using eval. Undefined function 'workspacefunc' for input arguments of type struct
Is there anyway I can restore the default MATLAB path/paths ?
Use the MATLAB command
restoredefaultpath
to restore the MATLAB search path to the state at startup.
See MATLAB documentation for restoredefaultpath here
I had a similar situation where on startup, on Windows 8.1 64-bit, Matlab R2014b would show the same error and then no function would work.
In my case, restoredefaultpathcouldn't be found.
Setting the UserPath in the matlab setting file as suggested elsewhere also didn't help.
The solution was to remove the environment variable MATLABPATH that I had set as a convenience while trying to compile against Matlab libraries.
The error message could be more helpful...