How can I perform initial troubleshooting of MATLAB or Simulink errors?

225 views (last 30 days)
I'm looking for initial troubleshooting steps to take for MATLAB warnings and/or errors (upon product installation, startup, running examples, etc.).

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 May 2025
Edited: MathWorks Support Team on 6 Apr 2025
The following troubleshooting steps may help resolve MATLAB startup warnings/errors that occur after upgrading your MATLAB release, search path issues, and/or file shadowing issues. File shadowing occurs when two files with the same name are on the MATLAB path. The file with higher precedence gets called/loaded, while the other file with lower precedence is shadowed.
 
1. Save a copy of current MATLAB Search Path
It is important to take a backup of the current 'pathdef.m' file, which can be located by executing the following command in the MATLAB Command Window:
>> which -all pathdef
Ensure that you make a copy of the file by copying it in a location different than its current folder. This is because the steps of this procedure involve regenerating the MATLAB Search Path, including resetting the 'pathdef.m' file to its initial state. This procedure will further remove custom paths you may have added in the MATLAB Search Path.
The following MATLAB Answers post provides additional information for this step and how to back up custom paths: How will running the "restoredefaultpath" and "savepath" commands affect my custom paths and how do I back up my custom paths?
 
2. Restore MATLAB Search Path and rehash path cache
After completing step 1, please execute the following commands in the MATLAB Command Window to restore the default MATLAB Search Path and rehash the toolbox cache:
>> restoredefaultpath >> rehash toolboxcache
Restoring the MATLAB Search Path resets it to its initial state. Please refer to the 'restoredefaultpath' page for more details.
Rehashing the toolbox cache updates the list of known files and classes for all folders on the MATLAB Search Path. Please refer to the 'rehash' documentation page for more details.
For Simulink users, refreshing customizations in the current MATLAB session may be helpful. In addition to the above two commands, please execute the following command in the MATLAB Command Window: 
>> sl_refresh_customizations
Please refer to the 'sl_refresh_customizations' documentation page for more details.
3. Save MATLAB Search Path
After completing step 2, please use MATLAB/Simulink to see if the initial issue was resolved. Then you may want to save the new MATLAB search path to the 'pathdef.m' file by executing the following command:
>> savepath
Please refer to the 'savepath' documentation page for more details.
You can then start adding your custom paths (if any) following the backed-up file and the procedure from the following documentation page: Change Folders on Search Path

More Answers (0)

Categories

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

Products

Community Treasure Hunt

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

Start Hunting!