How do I programmatically change the MATLAB Desktop current folder to the folder of an open script?
조회 수: 2 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2022년 11월 23일
답변: MathWorks Support Team
2023년 1월 24일
I would like to put a command in my open script which changes the MATLAB current folder to the folder which that script is in. Is there a command that can do this?
채택된 답변
MathWorks Support Team
2022년 11월 23일
On MATLAB Desktop, adding the command below to a ".m" file (not a Live Script) and executing the script changes the MATLAB current folder to the folder of that ".m" file:
cd(fileparts(which(mfilename)))
On MATLAB Desktop, adding the command below to a Live Script (".mlx") and executing the Live Script changes the MATLAB current folder to the folder of that Live Script:
cd(fileparts(matlab.desktop.editor.getActiveFilename))
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!