How do I pass input parameters when running a script within another?

20 ビュー (過去 30 日間)
Matteo Graziosi
Matteo Graziosi 2021 年 12 月 2 日
編集済み: Stephen23 2021 年 12 月 2 日
I want to write a script (Script_B to be clearer) with a cycle so that it runs another script (Script_A) multiple times. Script_A extracts data from other files, so it needs input parameters (e.g. filename). I've tried with:
for j = 0:9
run Script_A(input_1, input_2, input_3, input_4);
end
However MatLab reads the inputs as part of Script_A's name and returns the errors:
Error using run (line 46)
Script_A(input_1, input_2, input_3, input_4) not found.
Error in Script_B (line 4)
run Script_A(input_1, input_2, input_3, input_4);
What can I do?
  1 件のコメント
Stephen23
Stephen23 2021 年 12 月 2 日
編集済み: Stephen23 2021 年 12 月 2 日
Scripts do not have input arguments, so your syntax will not work:
Convert your script to a function and then call that:

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

回答 (1 件)

Star Strider
Star Strider 2021 年 12 月 2 日
Create ‘Script_A’ as a function with those inputs and specify an output value array that it will return.
See the documentation section on Function Basics for details.
.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by