필터 지우기
필터 지우기

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