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

5 visualizaciones (últimos 30 días)
AK
AK el 26 de Mzo. de 2024
Comentada: AK el 27 de Mzo. de 2024
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 ?

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 26 de Mzo. de 2024
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 comentario
AK
AK el 27 de Mzo. de 2024
Thanks .
It worked with set_param('modelname/blockname','value','numberhere ');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink Environment Customization en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by