Is there a way to modify the path for ".." ( shortcut ) ?

6 Ansichten (letzte 30 Tage)
Darius Vesa
Darius Vesa am 29 Jun. 2022
Kommentiert: Darius Vesa am 30 Jun. 2022
Greetings,
Whenever I download repositories from my team from other departments they have scripts which are runned from a path which contain ".." and I do not know how to change on my MATLAB workstation the parent path for it. For example:
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?

Antworten (1)

Walter Roberson
Walter Roberson am 29 Jun. 2022
The effect of this is that when you start MATLAB, MATLAB would automatically cd() to that directory.
I do not generally recommend this, except for the case where you have moved your hierarchy of MATLAB files to an unusual location.
  2 Kommentare
Darius Vesa
Darius Vesa am 30 Jun. 2022
Ok. I used "userpath" and finally found my default path and if a change that to corelate with the ".." It works, but the problem is that I cannot change the userpath to match my desired path.
For example my user path is:
C:\Documents\MATLAB
but my project parent directory is in:
C:\Documents\MATLAB\Projects\99_OEM_GSM\
So right now if I change in the scripts ( which are a lot ! )
MODEL_CONFIG='..\03_config\config.m';
to
MODEL_CONFIG='..\Projects\99_OEM_GSM\03_config\config.m';
it works. But I would really like to globaly change the userpath or the realitve path from this C:\Documents\MATLAB to this C:\Documents\MATLAB\Projects\99_OEM_GSM\ so that I do not need to modify any of the script file.
Darius Vesa
Darius Vesa am 30 Jun. 2022
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....

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by