フィルターのクリア

Why is simulink model called with an invalid flag?

9 ビュー (過去 30 日間)
Seunguk Lee
Seunguk Lee 2020 年 9 月 14 日
コメント済み: Seunguk Lee 2020 年 9 月 14 日
I made a simulink model with four variables in it.
The code
var1 = 0.14
var2 = 0.35
var3 = 1000000
var4 = 1000
I = sim('modelname.slx')
works properly, but when I wrap this up in the function like
function I = mdlname(var1, var2, var3, var4)
I = sim('modelname.slx')
end
mdlname(0.14, 0.35, 1000000, 1000)
It says that the model was called with an invalid flag.
Why is this happening?

採用された回答

stozaki
stozaki 2020 年 9 月 14 日
Hello Seunguk,
If you call a function, you need to use variables in the function workspace.
ret = mdlname(0.14, 0.35, 1000000, 1000);
function I = mdlname(var1, var2, var3, var4) %#ok<INUSD>
I = sim('modelname.slx','SrcWorkspace','current');
end
document : Input Arguments section of sim.
Regards,
stozaki
  1 件のコメント
Seunguk Lee
Seunguk Lee 2020 年 9 月 14 日
Problem solved. Thanks a lot stozaki!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by