How to apply App Designer output to Constant of simulink model ?
조회 수: 5 (최근 30일)
이전 댓글 표시
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 ?
댓글 수: 0
채택된 답변
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 )).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!