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

I'm looking for initial troubleshooting steps to take for MATLAB warnings and/or errors (upon product installation, startup, running examples or my MATLAB code, etc.).

 Accepted Answer

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 verify that the initial issue has been 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
NOTE: After running 'restoredefaultpath', support package paths are removed from the MATLAB Search Path. Please restart MATLAB to restore your support packages, as explained in this MATLAB Answer: How do I restore Support Packages after running 'restoredefaultpath'?

More Answers (0)

Categories

Products

Community Treasure Hunt

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

Start Hunting!