How to send a value to position "i" from app designer to a constant block in Simulink that has 5 dimmensions?

7 次查看(过去 30 天)
Hello all,
I am creating an app with MATLAB App Designer that interfaces with Simulink. I am able to send values from the app using the set_param command. For example, to send a value to a 1D constant block in Simulink I use this line of code:
set_param('nameOfModel/nameOfBlock','Value',5);
Now, since I a sending a lot of values to different constant blocks, I was thinking creating one single 5D constant block, and pass different values to each position of this block. I have tried several things with no luck.
Does anybody know a way to making this work or maybe using another approach?
Thanks for the help!!

采纳的回答

Fangjun Jiang
Fangjun Jiang 2020-7-21
It certainly can be done but I am not sure if it would be "better". Note you have to set 'Value' as '5', not 5.
when you set the value, you have to use
set_param(Block,'Value', mat2str(1:5))
when you try to modify the 3rd value, you have to do several steps
Value=get_param(Block,'Value');
Mat=str2double(Value);
Mat(3)=30;
set_param(Block,mat2str(Mat))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by