How do I save path for future sessions?

16 vues (au cours des 30 derniers jours)
Asiegbu Kanu-Asiegbu
Asiegbu Kanu-Asiegbu le 19 Nov 2017
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))

Réponses (1)

Walter Roberson
Walter Roberson le 19 Nov 2017
Modifié(e) : Walter Roberson le 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.

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by