Why am I unable to set a breakpoint in a file within a directory that is on the MATLAB path due to a relative path being in the path?
3 views (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Edited: MathWorks Support Team
on 1 Mar 2021
If I am in my "C:\Work\dir1" directory, and I add the directory "..\dir2" to my MATLAB path using:
addpath('..\dir2')
I can run a file in that directory normally. When I try to set a breakpoint in a file in that directory using the DBSTOP function, it appears to work -- DBSTOP does not return an error. In addition, the DBSTATUS function shows that the breakpoint has been set. However, when I open the file in the MATLAB Editor, no such breakpoint has been created. Finally, attempting to set a breakpoint in that file within the Editor causes a dialog to appear telling me that the file is not on the MATLAB path.
Accepted Answer
MathWorks Support Team
on 1 Mar 2021
Edited: MathWorks Support Team
on 1 Mar 2021
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
The behavior of the MATLAB Editor and the DBSTOP function when a file is "visible" to MATLAB only due to a relative path in the MATLAB path is a bug within MATLAB. We do not recommend that you use relative paths in your MATLAB path, as this is not robust -- changing directories can render files that you expected to be able to use no longer "visible" to MATLAB due to the directory relative to which the relative path is referring having changed.
As a workaround, you can use the following commands to determine the parent directory of the current directory, and replace the relative path ".." with the parent directory's absolute path:
P = pwd;
cd('..');
ParentDirectory = pwd;
cd(P);
0 Comments
More Answers (0)
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!