Run command not working

20 ビュー (過去 30 日間)
Denis Gorman
Denis Gorman 2023 年 8 月 21 日
コメント済み: Denis Gorman 2023 年 8 月 22 日
I have a script which runs various other .m files, using...
run('filename.m');
When I run the script, the .m files are not run. I can manually run them by opening them in the workspace and clicking 'run'. I can also run the .m files by entering in the command window....
filename % (i.e. without anything beforehand, and without the .m)
Can anyone help me understand why the run command doesn't work? As best as I can tell, the File directory and working folder are setup correctly
The script works for my colleagues - The only difference I'm aware of is that I have to run Matlab as an administrator, whereas my colleagues do not
  7 件のコメント
Stephen23
Stephen23 2023 年 8 月 22 日
"My indicator for whether the .m file 'runs or not' (poor wording, apologies) is whether the new variable gets created in my workspace when I run the .m file"
If the RUN command is called within a function or class method then it uses the workspace of that function or method, i.e. the variable is created inside the function/method workspace and will not be visible in the base workspace:
That could explain the behavior you are seeing:
You should also check the MATLAB evaluation status in the bottom left corner of the IDE:
If MATLAB is busy it may not update the workspace.
Denis Gorman
Denis Gorman 2023 年 8 月 22 日
Huge thanks for the responses. Replacing 'run' with a simple call out for the filename appears to be effective. Comments noted on the appropriate/inappropriate scenarios for using run. Thanks!

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by