- In the Windows File Explorer, right-click the "pathdef.m" file and select "Properties".
- Go to the "Security" tab.
- Click "Edit…".
- Under "Group or user names", select the applicable user/group name, or do the following to grant permission for every user:
- Click "Add".
- In the "Enter an object name to select" area, enter "Everyone", and click "Check Names". The "Everyone" you entered should be underlined. Click "OK".
- Under "Permission for Group/User/Everyone", click the “Allow” check box for “Full control”.
- Click "OK".
Why do I get "Error using eval: Undefined function 'workspacefunc' for input arguments of type 'struct'." when starting MATLAB?
552 views (last 30 days)
Show older comments
MathWorks Support Team
on 14 Oct 2016
Edited: MathWorks Support Team
on 18 Oct 2024
Why do I get the following error when starting MATLAB?
Error using eval
Undefined function 'workspacefunc' for input arguments of type 'struct'.
Accepted Answer
MathWorks Support Team
on 17 Oct 2024
Edited: MathWorks Support Team
on 18 Oct 2024
This error indicates that MATLAB is unable to read your "pathdef.m" file. It can occur because the permissions set on your "pathdef.m" file prevent the user running MATLAB from reading it, or your "pathdef.m" file has become corrupted. Try the troubleshooting steps below:
1) Change "pathdef.m" File Permission
First, locate your "pathdef.m" file. Run the following command in the MATLAB Command Window:
>> which pathdef
This command will return the location of your "pathdef.m" file. This location is typically the following:
<matlabroot>/toolbox/local/pathdef.m
On Windows, this would be the following path:
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 & 11:
If you encounter issues related to changing permissions, please contact your Windows System Administrator for further help.
Mac & Linux:
Open a terminal window and run the following command to update the permissions for "pathdef.m":
sudo chmod 777 $MATLABROOT/toolbox/local/pathdef.m
2) Regenerate "pathdef.m":
If the above steps do not resolve the issue then your "pathdef.m" file may be corrupted. Please regenerate "pathdef.m" by performing the following steps:
1. Ensure MATLAB is not running and delete "pathdef.m".
2. Open MATLAB (you will see errors).
3. Run the following commands in the MATLAB Command Window:
>> restoredefaultpath
>> rehash toolboxcache
>> savepath
4. Rename the temporary file created in <matlabroot>/toolbox/local to "pathdef.m".
5. Restart MATLAB.
3) Try to fix the search path
If you are also seeing the message "MATLAB did not appear to successfully set the search path", follow the possible solutions from the link below:
4) Reinstall MATLABAs 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 Comments
Walter Roberson
on 13 Jun 2021
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
on 13 Jun 2021
Windows 10:
Using Windows Explorer,
- Right-click on “pathdef.m” file, select “Properties” (it will probably be the last item in the menu)
- Go to “Security” tab (near top of Properties) and click "Edit" in the "Change permissions" line.
- You will be shown a tab that has the filename near the top and "Group or user names" below that.
- Click “Add".
- In the "Enter an object name to select" area, enter "Everyone", and click "Check Names". The "Everyone" you entered should become underlined. Click OK
- In the "Permissions for Everyone", list, click "Modify". This will also enable several other entries. Click OK.
- You are now back at the Security properties for the file. Click OK
More Answers (0)
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!