How to send a value to position "i" from app designer to a constant block in Simulink that has 5 dimmensions?
5 次查看(过去 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!!
0 个评论
采纳的回答
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 Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!