How do I save path for future sessions?

16 次查看(过去 30 天)
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))

回答(1 个)

Walter Roberson
Walter Roberson 2017-11-19
编辑:Walter Roberson 2017-11-19
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.

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by