About changing and adding path

3 visualizaciones (últimos 30 días)
Raphaël
Raphaël el 10 de En. de 2019
Editada: Paul Dankoski el 11 de Jul. de 2019
Hi,
I guess I'm somewhat confused how to properly use the addpath function in matlab. At the moment, I have multiple functions, data files and main code all classify in several different folders. At the moment, when I run a code, I have multiple addpath at the beggining for each of those folders. For example:
addpath('C:\Users\Bob\Documents\ProjectX');
addpath('C:\Users\Bob\Documents\ProjectX\functions');
addpath('C:\Users\Bob\Documents\ProjectX\data\experience1');
addpath('C:\Users\Bob\Documents\ProjectX\data\experience2');
addpath('C:\Users\Bob\Documents\ProjectX\AliceFunctions\mapping');
The main issue is all the folders also have subfolders and it starts to be pretty heavy and lengthy to call each indidual subfolder. It really seems inefficient to me. Is there a better way to do it and calling only the first folder ProjectX? Just adding this path doesn't seem to be enought for Matlab to find all the functions and data in the subfolders in this folder.
Thank you for your help.
RMT

Respuestas (2)

David Goodmanson
David Goodmanson el 11 de En. de 2019
Editada: David Goodmanson el 11 de En. de 2019
Hi Raphael,
See 'genpath' for how to create a string of a folder and all its subfolders (with some exceptions), then you can use addpath just once on that string.
Have you checked out 'pathtool'? It also has the option of adding all subfolders. Since it's an interactive tool, it is at its most useful if you use it once, hit 'save' and make the change quasi-permanent (if your environment allows this).
If the your total number of paths is not overly large, you could save the paths for all your applications and be done with it until there is a new folder to add.

Paul Dankoski
Paul Dankoski el 11 de Jul. de 2019
Editada: Paul Dankoski el 11 de Jul. de 2019
addpath(x) slowness was also addressed in this topic, which might be relevant to your case.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by