How do I save path for future sessions?
16 views (last 30 days)
Show older comments
I'm trying to finish the MATLAB code shown below. What the code does now is that it adds a folder and subfolders to the MATLAB path. The problem I am having is trying to save the path for future sessions and not just current sessions.I know you can save the path with the set path toolbox but I need to include the save for future sessions in the code format. I think the correct way to go might be the savepath function, however, I do not have a pathdef.m file in the folder of the script shown below I am trying to run. Also, I do not want to lose my existing MATLAB path. Thanks,
%%%%%%%%%%%%%%
location = pwd
addpath(genpath(location))
0 Comments
Answers (1)
Walter Roberson
on 19 Nov 2017
Edited: Walter Roberson
on 19 Nov 2017
If you cannot save the path to a pathdef.m then you will need to have the addpath() in your code.
If this is just an optimization, to save the trouble of tracking down the files, then you might want to consider using setpref() and getpref() to remember the path -- but keep in mind that setpref and getpref have their own cost.
0 Comments
See Also
Categories
Find more on Search Path 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!