How to apply App Designer output to Constant of simulink model ?

조회 수: 5 (최근 30일)
AK
AK 2024년 3월 26일
댓글: AK 2024년 3월 27일
Can anyone tell me what I am missing ?
*****************************
With push button callback I am starting model simulation with
set_param(app.Modelname,'SimulationCommand','start');
**********************************************
I have discrete knob in App designer panel. Which I want to use to give input as (modelsignal=0,1,2)
My call back is as below
********************
knob = app.DynamicModeKnob.Value;
if strcmp(knob,'Up')
updnsw = 1;
assignin('base','modelsignal',updnsw);
elseif strcmp(knob,'Down')
updnsw = 2;
assignin('base','modelsigna1',updnsw);
else
updnsw = 0;
assignin('base','modelsignal',updnsw);
*******************************************************
Simulink Model has constant with name 'modelsignal'.
When i run the app and give command to run model,
In workspace I see modelsignal value changing as 0,1,2 when i press knob to off,Up,Down.
Problem is :
Model constant doesnt get value as 0,1,2 it remains 1.
Can anyone help me to understand what step i am missing ?

채택된 답변

Fangjun Jiang
Fangjun Jiang 2024년 3월 26일
The workspace value is compiled/built for simulaiton only once when the model is initialized. It will not be updated to the model simulation when the value is changed during the simulaiton.
You may use set_param() to update a block parameter while the simulation is running if this parameter is tunable. For example, if 'modelsignal' is used by a Constant block, you may be able to set_param('ConstantBlock','value',num2str(updnsw )).
  댓글 수: 1
AK
AK 2024년 3월 27일
Thanks .
It worked with set_param('modelname/blockname','value','numberhere ');

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by