How do I programmatically change the MATLAB Desktop current folder to the folder of an open script?
4 ビュー (過去 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!