One Matlab version breaks when I fix errors in the other one, after getting errors in startup: Unrecognized function or variable + warning: name is nonexistent.
6 views (last 30 days)
Show older comments
I have multiple Matlab versions but mainly use 2019b and 2021b. Last week, I got many warnings in Matlab 2021b that said:
"Warning: Name is nonexistent or not a directory: ..." with many of the matlab21b/toolbox and matlab21b/examples folders.
Then, this error:
Error using builtin
Can't find the resource file 'toolbox/matlab/graphics/hg/hgrc.m' needed by '/export01/local/matlab21b/bin/glnxa64/libmwhg.so'
I looked for the error and found this response: https://www.mathworks.com/matlabcentral/answers/872683-error-after-installing-matlab-2021a#toggle-comments
I followed the instructions and it fixed my Matlab21b; however, when I opened 2019b, it had the errors now... After fixing it, the errors returned to 2021b. So basically, my question is how can I fix both Matlab versions without breaking the other?
EDIT & SOLUTION:
The main problem was related to not being able to have an independent pathdef.m for each version, as I could only store it in my home folder (no admin rights). However, I asked the question again two years after, and I was told to use a startup.m script for both of my versions that would set up the paths that I needed and it could be accessed by both versions, so I created a file through
edit(fullfile(userpath,'startup.m'))
that looks like this:
%------------- ADD PATHS -----------------------------%
addpath /home/user/Scripts
addpath /home/user/matlab
addpath /meg/meg1/software/brainstorm3
Then I opened each of the MATLAB versions and added the startup file to the path. And now, I can add whatever path I want to without dealing with the pathdef.m file.
2 Comments
Steven Lord
on 21 Sep 2023
Are the two installations somehow sharing a preferences directory? What does this command show when run in each of your MATLAB installations?
prefdir
Alternately perhaps your MATLAB path is getting corrupted by each MATLAB session saving its version in the same place. What does this command show in each of your MATLAB installations?
which -all pathdef
Answers (1)
Kshittiz
on 21 Sep 2023
Hi Zaida,
I understand that you are using two MATLAB versions and encountering “Unrecognized function or variable” error while using them. You have tried using the “restoredefaultpath” command but although it solves the issue in the MATLAB version you run it in, it causes the other version to break.
You can refer to the following MATLAB Answer thread which offers guidance on adding the Path to the toolbox mentioned in the error message you are getting.
I hope this workaround will help you in resolving the issue.
Thanks and Regards,
Kshittiz
2 Comments
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!