How do I access a .m file in a subfolder?
古いコメントを表示
Hi Matlab community,
how do I access a .m file in a subfolder? In my case, the name of the subfolder would be "Workspace" and the name of the file in the subfolder would be "constants.m".
Best regards
4 件のコメント
Stephen23
2022 年 9 月 5 日
"how do I access a .m file in a subfolder?"
What exactly do you mean by "access" ? Do you want to read/write to the textfile, or run it (if it is a script) or call it (if it is a function) or copy/move it to another location or something else? Please be specific.
Benjamin Pommer
2022 年 9 月 5 日
Stephen23
2022 年 9 月 5 日
"I want to open a .m file with a command in another .m file."
This is still unclear: do you want to FOPEN the file? (i.e. open the file for reading/writing using FSCANF/FPRINTF/...)
Or do you mean open in the sense of using some app installed on your computer to open the file? Or something else?
When you are not precise with explaining what you want, then you delay getting an answer.
Benjamin Pommer
2022 年 9 月 5 日
採用された回答
その他の回答 (1 件)
Image Analyst
2022 年 9 月 5 日
Add it to your path. In your main script, have this line
addpath(genpath(pwd));
After that you should be able to call any other scripts or functions in your "Workspace" subfolder or any other subfolders of where your main script lives.
savepath;
カテゴリ
ヘルプ センター および File Exchange で Search Path についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!