How to sync Matlab file location and current pwd of command window?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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 Exchange에서 Search Path에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!