Temporary remove all added paths in matlab

I have added many paths to matlab and now I want to share my code, but I don’t know exactly which function (in which path) I should add to my shared code. Every time I need to add a missing function, it really bothers me and the users who are using the code.

So, I would like to restore the matlab path to its original case. Is there a way to do this in Matlab? I also want to save a backup of my currently appended path in a .m file and use it later when done.

+3


source to share


1 answer


To restore the path to the default - http://www.mathworks.com/help/matlab/ref/restoredefaultpath.html

restoreefaultpath sets the search path to include only folders for Installed MathWorks® products. Use restoreefaultpath when you are having trouble finding.

restoredefaultpath; matlabrc sets the search path only to include the folder for MathWorks installed products and fixes the search path for startup problems.

And save the current path - http://www.mathworks.com/help/matlab/ref/savepath.html



savepath updates the MATLAB® search path for all users of the system so that the path can be reused in a future session. savepath saves the search path to the pathdef.m file that MATLAB resides at when it starts up, or to the current folder if the pathdef.m file exists there.

Or you can just store the path in a variable p = path;

and restore it later path(p);

. If the path is stored in pathdef.m

, the call pathdef

returns a string that can be used to set the stored path.

+5


source







All Articles