フィルターのクリア

How can I set a block of code from one m file into another m file?

3 ビュー (過去 30 日間)
Md Nahid Hossain Khan
Md Nahid Hossain Khan 2019 年 10 月 8 日
コメント済み: dpb 2019 年 10 月 8 日
I need to run a code to simulate result. I have several inputs as m file and I need to put a block of code into another input m file. How can I do that?
suppose, case1.m, case2.m. bob.m, and paul.m are m files and these are the input for simulation.
I have to write the structural array into a seperate m file during running the simulation and put it into case2 anyhow even though the case2.m doesn't contain this structural array normally. How can I do that?
a=case1;
b=case2;
c=bob;
d=paul;
run=showresult(a,b,c,d);
plot(run);
header = {'Name' 'Type' 'Address' 'Phone No'};
case2.ext=cell2table({
1.0000 2.0000 0.1000 0.1000
2.0000 2.0000 0.1000 0.1000
3.0000 2.0000 0.1000 0.1000
4.0000 2.0000 0.1000 0.1000
}, 'VariableNames',header);
  1 件のコメント
dpb
dpb 2019 年 10 月 8 日
Write as functions and pass the struct as an argument instead...or, you could use nested functions perhaps and then the included function could have access to the variables contained in the higher scope of the containing m-file/function.
See documentation for function and the supporting discussion on program structure for details, examples...

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

回答 (0 件)

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by