I'm working on a project containing some subprojects. Each subproject is located in a own folder.
projDir/subProj1
/subProj2
and so on. Each subproject is a standalone running project. But now I want to use some functions of i.e. subProj1
in subProj2
. But the functions in subProj1
should not be visible in general. So it is no good idea, to add the subProj1
-path to the MATLAB-Path generally. Hence, I want to add this path in my .m-file stored in subProj2
and after finishing this script, the path should be removed (automatically) by it's own. Is there any possibility, to add a path temporarily to the MATLAB-path variable?
The addpath
function only adds the files/folder to your path for the current Matlab session, assuming you don't call savepath
. You also might find the genpath
function helpful if you want to add subfolders.
You can use path(path_to_add,path)
to add a path to the current path variable. Unless you do savepath
you won't affect the global path.
I would do path(strcat(pwd,'\subProj1',path)
etc. in the config .m script you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With