How to fix MATLAB errors arise from changing the search path?

The Matlab software installed on my computer(windows OS) shows a lot of errors when I tried to change the search path by using addpath command , suddenly MATLAB shows errors even for the startup and doesn't recognize any functions or variables or any commands
I usually saved my projects in C:\Program Files\MATLAB\R2016a\bin and when I tried to change the search path to C:\Users\Bita\Documents\MATLAB by using
addpath('newpath')
and also usnig
mypath=fullfile(userpath,'foldername')
addpath(mypath)
and then MATLAB is showing iterative errors while I'm not running any programs, even for MATLAB startup ,It shows a lot of errors
The errors are:
Undefined function or variable 'matlabrc'.
Undefined function or variable 'which'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable 'rmiml.getAll'.
Undefined function or variable 'fschange'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Undefined function or variable
'internal.matlab.desktop.editor.isSystemObjectFile'.
Undefined function or variable 'rmiml.visibleInToolstrip'.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.mathworks.mlwidgets.graphics.ModelStateFactory.createNoSelectionModelState(ModelStateFactory.java:251)
at com.mathworks.mlwidgets.graphics.PlotToolSetFactory$3.parseComplete(PlotToolSetFactory.java:123)
at com.mathworks.mlwidgets.graphics.ModelStateFactory$ProductInfoListener$1$1.run(ModelStateFactory.java:1032)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I'll be very grateful to have your opinions about how to fix MATLAB software
Thanks

댓글 수: 5

Try using
restoredefaultpath
However when I look at the list of things that are failing, I suspect even restoredefaultpath might fail.
You might need to find pathdef.m and delete (or rename) it. And possibly you might need to rename or delete your prefdir directory.
Thanks
I used restoredefaultpath in command , as you have said, Matlab shows undefined function or variable
and for pathdef.m I searched I don't have this file , prefdir also shows the same error.
Maybe the only way is reinstalling MATLAB software?
On MS Windows your prefdir is typically
'C:\Users\username\AppData\Roaming\MathWorks\MATLAB\R2016a'
Thanks
But I don't have AppData folder in this path
from Home Menue , Environment Tab , set path , just shows error preferences part in General , initial working folder, I tested the working folder from previous MATLAB sessions , also I tried specify the full path :C:\Program Files\MATLAB\R2016a\bin
but It doesn't have any resault.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2019년 6월 19일

0 개 추천

"I usually saved my projects in C:\Program Files\MATLAB\R2016a\bin"
You have corrupted MATLAB . You need to move your projects somewhere else for the moment, then uninstall MATLAB and reinstall it. Then after that, you need to never save your MATLAB files underneath C:\Program Files

댓글 수: 3

Thank you very much
Ok, but I have a question, For this MATLAB software I didn't define the search path at first, so the pojects automatically have been saved in the default path which was in the MATLAB installation path:
C:\Program Files\MATLAB\R2016a\bin.
So when I want to reinstall MATLAB software, how can I be sure that MATLAB doesn't save projects in the same path and this problem won't happen again?
Thanks
"...the default path which was in the MATLAB installation path"
The very first folder on the default search path is the userpath folder, which is located in their personal documents folder. This is clearly explained in the documentation:
"The MATLAB userpath folder, which is added to the search path at startup, and is the default location for storing user files"
Note that it also clearly describes where users should store their files! For me, this is the first folder listed on the default Search Path:
C:\Users\stephen.cobeldick\Documents\MATLAB
and this is the same folder that is returned by userpath, exactly as the documentation states. The path you showed is NOT on the default MATLAB Search Path:
C:\Program Files\MATLAB\R2016a\bin % NOT default Search Path!
So you must have made the change yourself, or some third-party tool made that change, or you are confusing the MATLAB Search Path with something else (e.g. the Windows System Path, which quite possibly will include the MATLAB installation folder).
"how can I be sure that MATLAB doesn't save projects in the same path and this problem won't happen again?"
It doesn't happen by default, so you shouldn't need to do anything.
I second the suggestion of reinstalling Matlab. Currently your errors might be caused by your corrupted installation, or a bug in your code. There is not really an easy way for you to tell which error is caused by which problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

질문:

2019년 6월 19일

댓글:

Rik
2019년 6월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by