Open and run a .m in matlab into an another .m file

175 ビュー (過去 30 日間)
Ivan Mich
Ivan Mich 2020 年 4 月 2 日
コメント済み: Ivan Mich 2020 年 4 月 2 日
Hello,
I have a quastion about a code I am creating. I have a code in a .m file, let's name it as "first.m". But in the "first.m" i would like to write a command in this script in which I would like to run and execute an another .m file, let's name it "second.m" file, in the ssame directory.
Could anyone help me to make it?

採用された回答

Walter Roberson
Walter Roberson 2020 年 4 月 2 日
Inside first.m code a line
second; %invokes second.m
This will work provided that second.m is on your MATLAB path (such as being in the same directory). If it is not on your MATLAB path and it is a script (rather than a function) then you can use
run('appropriate/directory/goes/here/second.m')
  4 件のコメント
Walter Roberson
Walter Roberson 2020 年 4 月 2 日
What error does the command window show?
Ivan Mich
Ivan Mich 2020 年 4 月 2 日
I solve it! Thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFile Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by