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

1.052 views (last 30 days)
Why do I get the following error when starting MATLAB?
Error using eval
Undefined function 'workspacefunc' for arguments of type 'struct'.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 17 Feb 2021
Edited: MathWorks Support Team on 17 Feb 2021
This answer was flagged by Stefanie Schwarz
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:
  1. Right-click on “pathdef.m” file, select “Properties”.
  2. Go to “Security” tab and click “Advanced”.
  3. Go to “Owner” tab and click “Edit”.
  4. Click “Other users or groups…”
  5. Enter “Everyone" and click “Ok”
  6. Under “Change owner to”, select “Everyone”. Click “Ok”
  7. Click “Edit…”
  8. Under “Group or user names”, select “Everyone”
  9. Click “Allow” check box for “Full control”
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
  1. Rename the temporary file created in <matlabroot>/toolbox/local to pathdef.m
  2. 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 .
  13 Comments
PETER KALADIUS ZAKI
PETER KALADIUS ZAKI on 8 Jul 2022
Thank you very much. @Walter Roberson
I had this issue when I move between Admin account and another user, and now it is gone and pathdef.m is accessible in both accounts.

Sign in to comment.

More Answers (1)

BINGXIN YAN
BINGXIN YAN on 1 Jul 2022
Edited: BINGXIN YAN on 1 Jul 2022
For me, MATLAB R2017b Windows 8, this works for me.
  1. Close matlab
  2. Run as administrator.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by