フィルターのクリア

Passing a block paramater value from App Designer to Simulink

2 ビュー (過去 30 日間)
Ahmed Hassan
Ahmed Hassan 2018 年 8 月 22 日
回答済み: Ashutosh Prasad 2018 年 8 月 29 日
Hi, I'm using App Designer to build an app to control a Simulink model. I want to change a block parameter value in Simulink and run, so I have the following lines executed when I hit the "run" button
function RunSimButtonPushed(app, event)
set_param('MySim/Mode1','Value','app.Mode1.Value');
SimOutput=sim('MySim');
app.SimOut=SimOutput;
end
I had defined a global parameter called Mode1 in my app
properties (Access = public)
SimOut % Output from Simulink model run
Mode1 % mode1 value, to be used by the Simulink model
end
When I run the app it gives me this error: "Undefined variable "app" or class "app.Mode1.Value""
Any ideas how to fix that? Thanks.
-Ahmed

回答 (1 件)

Ashutosh Prasad
Ashutosh Prasad 2018 年 8 月 29 日
The quotes in the third argument of the set_param command seem quite unnecessary. If app.Mode1.Value holds a numerical value you need to typecast it to string data type using num2str function.

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by