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

5 views (last 30 days)
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!!

Accepted Answer

Fangjun Jiang
Fangjun Jiang on 21 Jul 2020
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))

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!