How to sync Matlab file location and current pwd of command window?

3 ビュー (過去 30 日間)
Frank Uhlig
Frank Uhlig 2025 年 4 月 8 日
コメント済み: Manikanta Aditya 2025 年 4 月 8 日
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?

回答 (1 件)

Stephen23
Stephen23 2025 年 4 月 8 日
編集済み: Stephen23 2025 年 4 月 8 日
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).

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by