Why is simulink model called with an invalid flag?
4 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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
Regards,
stozaki
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!