How to sync Matlab file location and current pwd of command window?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
My Matlab code sits in a loooong file name folder and my command window just in
>> pwd
ans =
'/Users/uhligfd/matlabin/myREF24'
How can I successfully "run" my code and get answers inside the short name command window. Some syncing of sorts seems needed, but how to sync the two locations?
0 Kommentare
Antworten (1)
Stephen23
am 8 Apr. 2025
Bearbeitet: Stephen23
am 8 Apr. 2025
Do NOT use CD for this.
This is exactly what the MATLAB Search Path is for:
Simply add the folder containing your code to the Search Path (e.g. using ADDPATH) and then you can call it from anywhere, regardless of where your current directory is.
"syncing" directories is not a concept that exists in MATLAB. Use CD from the command line when developing and testing things, but not for actually running your code (it is slow and makes debugging harder).
1 Kommentar
Siehe auch
Kategorien
Mehr zu Search Path finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!