Allows the user to transfer your search path from an old MATLAB release to a new release
Updated 18 Mar 2015

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

I seem to be constantly replacing my old MATLAB release with a new one. So generally two releases a year, plus two beta versions per year. Each time, I need to update the search path for the new release. In my case, this means adding several dozen of my own toolboxes, plus a few more that I have downloaded from the file exchange. Some of them go on the end or the beginning of the path, as is my preference. Honestly, this takes up some time to redo all of those directories, because they do not all lie in the same place, and some of those directories have subdirectories that I do not want on the path. So I end up spending some time to redo the new search path. In fact, this is the main reason why I am sometimes slow in downloading a new release.
The solution should be for MATLAB to offer a way to export your search path from the old release as a file, then be able to import those path directories into the path of the new release. This should be easy to do, but I've not yet seen anything in the path tools from MathWorks to do it. So I wrote my own tool to solve the problem.

1. In your old MATLAB release, run the export_search_path function. It will create two new files in the current directory. One is a .mat file, and the second an m-file called import_search_path.

2. Start the new MATLAB release, then CD to the same directory those files were saved to.

3. Run the import_search_path function from the command line.

Your new release will now have all of those directories added to the search path, and it will have taken you only a few seconds to accomplish the entire conversion. I've been careful to add those directories to your path in the same order they were before. All you need do now is delete the import_search_path.m file, and the __matlab__search__path__.mat file from that directory.

EXPORT_SEARCH_PATH takes apart your current search path, looking for directories that are not under the MATLABROOT directory structure. Then it subsets them into those that came in front of the MATLABROOT directories, and those that fall at the end. Any that fell in the middle for some reason, it adds to the end too.

Cite As

John D'Errico (2024). export_search_path (https://www.mathworks.com/matlabcentral/fileexchange/50087-export_search_path), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Search Path in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes