Error when opening two Matlab versions at the same time due to pathdef.m. How to fix it?

I use Matlab 2019b mainly because most of my project has been coded in that version, and therefore, I have set up a pathdef.m file with some functions that I've written. However, when I want to produce graphs, it is easier and nicer to use Matlab 2021b. Everytime that I open Matlab 2021b, while pathdef.m is in my home directory, it fails with multiple errors (see at the end). The only way of opening Matlab 2021 is for me to rename pathdef to something else, and then change it back when I want to use Matlab 2019b. This is not ideal for me, so I would appreciate if anyone could help me figure out how to be able to open both Matlabs without having to modify pathdef.m
Thank you!
ERROR CODE that appears immediately after opening Matlab:
Warning: Name is nonexistent or not a directory: /export01/local/matlab21b/toolbox/matlab/codeanalysis/analysis
... (many more warnings like these) ...
Warning: Name is nonexistent or not a directory: /export01/local/matlab21b/toolbox/nav/navslamapp
Error using builtin
Can't find the resource file 'toolbox/matlab/graphics/hg/hgrc.m' needed by '/export01/local/matlab21b/bin/glnxa64/libmwhg.so'
Error in matlab.graphics.internal.initialize (line 15)
suppressedOutput = evalc('builtin(''groot'');');
Error in matlab.internal.doc.services.getDocLanguageLocale (line 11)
sysLang = get(0, 'Language');
Error in matlab.internal.doc.csh.DocPageTopicMap.accessDocLanguage (line 74)
docLang = matlab.internal.doc.services.getDocLanguageLocale;
Error in matlab.internal.doc.csh.getLocalizedFileList (line 14)
docLang = matlab.internal.doc.csh.HelpTopicMap.accessDocLanguage;
Error in matlab.internal.doc.csh.findDocCatalogFiles (line 9)
files = matlab.internal.doc.csh.getLocalizedFileList(folder, shortname, extension);
Error in matlab.internal.doc.csh.DocPageTopicMap/retrieveHelpTargets (line 159)
files = matlab.internal.doc.csh.findDocCatalogFiles("cshapi_helptarget", obj.shortname);
Error in matlab.internal.doc.csh.DocPageTopicMap/mapSingleTopic (line 84)
retrieveHelpTargets(obj);
Error in matlab.internal.doc.csh.DocPageTopicMap/mapTopic (line 32)
docPage(i) = mapSingleTopic(obj, topicId(i));
Error in matlab.internal.doc.csh.HelpTopicMap/mapTopic (line 13)
docPages = mapTopic@matlab.internal.doc.csh.DocPageTopicMap(obj, topicId);
Error in matlab.internal.doc.csh.mapTopic (line 5)
helpPath = helpTopicMap.mapTopic(topicId);
Error in matlab.internal.language.introspective.getExtendedErrorCallback (line 5)
path = matlab.internal.doc.csh.mapTopic(shortname, topicId);
Unrecognized function or variable 'matlab.internal.debugger.breakpoints.initBreakpointsStoreInstance'.
Unrecognized function or variable 'matlab.internal.debugger.breakpoints.initBreakpointsStoreInstance'.

2 Comments

In all the versions of MATLAB I have, pathdef.m is in
$MLROOT/toolbox/local/pathdef.m
I don't know why you have pathdef.m in the home directory.
Because I don't have rights to add pathdef.m into that folder. I can only add it in my home directory.

Sign in to comment.

 Accepted Answer

Each version of MATLAB should have it's own pathdef and be independent. You can add paths to it with the Set Path button on the toolbar, but may not (at least in Windows) be able to modify it yourself. But you should not do that anyway. If you have custom paths you want to set up, do what I do : use addpath() in your startup.m file. I have my startup.m file in the Document/MATLAB folder. When I install a new MATLAB release, I just use the Set Path button to point to that folder so the startup.m file will get run. You only need to do this once, just after installation. Once that's done, all your versions of MATLAB will run the same startup.m file and thus will have the same folders added to the search path.

5 Comments

Oh, I am not completely sure where I can find the startup.m file to modify it. I am not working in Windows, but on Linux so it might be different, but where would you look for it? In the installation directory?
I found how to do it: https://www.mathworks.com/help/matlab/ref/startup.html
I will let you know if it works. Thank you!
The startup.m file can be anywhere on the path.
% the forum version doesn't have one
% but this is how you might look for it
which startup.m -all
'startup.m' not found.
... but if you don't have a means to set the path, and the user-accessible portions of the two paths are not unique, then you don't have anywhere to put two unique startup.m files without them both being seen by the two installed versions of MATLAB. Should I assume this is some sort of school/institutional thing?
It is an institutional computer, so I have very limited access to any folder outside my home.
I had understood from your previous comment that it was enough to have one startup.m file, as both Matlab versions could use the same one. Is that assumption wrong?
When I used "edit(fullfile(userpath,'startup.m'))", it opened a file that was inside my home/matlab folder. I have added the paths this way:
%------------- ADD PATHS -----------------------------%
addpath /home/user/Scripts
addpath /home/user/matlab
addpath /meg/meg1/software/brainstorm3
And I am about to test it out.

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!