Why do I get an "Error using eval: Undefined function 'workspacefunc' for arguments of type 'struct'." error when starting MATLAB?

조회 수: 975 (최근 30일)
Why do I get the following error when starting MATLAB?
Error using eval
Undefined function 'workspacefunc' for arguments of type 'struct'.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 1월 15일
편집: MathWorks Support Team 2023년 1월 12일
This error indicates that MATLAB is unable to read your pathdef.m file. This can occur because the permissions on your pathdef.m file prevent the user running MATLAB from reading it, but it can also occur if your pathdef.m file has become corrupted.
1) First, locate your pathdef.m file. From MATLAB, run the command
>> which pathdef
It is usually located at <matlabroot>/toolbox/local/pathdef.m. On Windows this would be:
C:\Program Files\MATLAB\RXXXXx\toolbox\local\pathdef.m
You may be able to resolve this issue by changing the permissions on your pathdef.m file.
Windows 10:
  1. Right-click the “pathdef.m” file and select “Properties”.
  2. Go to the “Security” tab.
  3. Click “Edit…”
  4. Under “Group or user names”, select the applicable user/group name, or do the following to grant permission for every user:
    1. Click “Add".
    2. In the "Enter an object name to select" area, enter "Everyone", and click "Check Names". The "Everyone" you entered should become underlined. Click OK
  5. Under "Permission for Group/User/Everyone", click the “Allow” check box for “Full control”.
  6. Click "OK".
Contact your Windows System Administrator for further help with the above.
Mac & Linux:
Open a Terminal window Run the following command:
sudo chmod 777 $MATLABROOT/toolbox/local/pathdef.m
2) If the above does not resolve the issue then your pathdef.m file may be corrupted or have errors. Regenerate pathdef.m by performing the following steps:
1. Delete pathdef.m
2. Open MATLAB again (you will see errors).
3. Run the following commands:
>> restoredefaultpath
>> rehash toolboxcache
>> savepath
4. Rename the temporary file created in <matlabroot>/toolbox/local to pathdef.m
5. Restart MATLAB.
3) As a last resort, reinstalling MATLAB should resolve the issue. If reinstalling MATLAB does not resolve the issue then there may be another application on your machine which is interfering with MATLAB. If the issue persists even after reinstalling MATLAB, please contact MathWorks support .
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 6월 13일
path() with one argument replaces the entire MATLAB path with the given argument. So path('VTA_FrontalCortex.m') replaces the entire MATLAB path with VTA_FrontalCortex.m (which is not even a valid path, as paths have to be directories.)
You should not use path to add an individual .m file onto the MATLAB path. You should use pathtool() for a graphic interface, or you should use addpath() and provide name of the directory (folder) that the .m file is in. For example it might be valid to
addpath(pwd)
Walter Roberson
Walter Roberson 2021년 6월 13일
Windows 10:
Using Windows Explorer,
  1. Right-click on “pathdef.m” file, select “Properties” (it will probably be the last item in the menu)
  2. Go to “Security” tab (near top of Properties) and click "Edit" in the "Change permissions" line.
  3. You will be shown a tab that has the filename near the top and "Group or user names" below that.
  4. Click “Add".
  5. In the "Enter an object name to select" area, enter "Everyone", and click "Check Names". The "Everyone" you entered should become underlined. Click OK
  6. In the "Permissions for Everyone", list, click "Modify". This will also enable several other entries. Click OK.
  7. You are now back at the Security properties for the file. Click OK

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by