Home > Back-end >  Is there a way to modify the path for ".." ( shortcut )?
Is there a way to modify the path for ".." ( shortcut )?

Time:07-01

Whenever I download repositories from my team from other departments they have scripts ( .m files )in MATLAB which are runned from a path file which contain ".." ( like a shortcut ) in their path link and I do not know how to change that on my MATLAB workstation, the parent directory for it. For example an .m file (script) which contains:

MODEL_CONFIG='..\03_config\config.m';
run(MODEL_CONFIG)

On their workstation this code works but on my workstation it says that: "there is no ..\03_config\config.m not found."

and I know that the ".." is the parent directory from the project. My question is:
"How can I change the default parent directory so that ".." can work on my workstation too?

Right now the only solution is to manually change in every script file the ".." with 'C:\Users%user%\Desktop\19_projectsMatlab\99_GSM_OEM' - and it this example 99_GSM_OEM would be the parent directory.

CodePudding user response:

What a .. means in a path is basically: go back one folder from your current working directory in Matlab. You can easily change this folder by clicking on this button in Matlab. If you want to change this folder during script execution you can do this with cd 'C:/Users/yourname/yourfolder/'

CodePudding user response:

Actually I am stupid. ".." is like "cd.." in MS-DOS.... I was in the wrong folder all the time. I am not supposed to be in the parent directory of the project when I run the main script. I am supposed to be in the folder directory where the main script is running (main.m).

So when I am in the folder directory of the main.m file the following link:

MODEL_CONFIG='..\03_config\config.m';

says go back with one folder from where the main.m file is and there should be the folder 03_config which you access. Thank you guys.

And if you have more subfolders in the folder in which is the main.m script "." - means the current location....

  • Related