Borrar filtros
Borrar filtros

Changing block parameter from MATLAB code seems to need 'pause'?

2 visualizaciones (últimos 30 días)
Nitzan
Nitzan el 24 de Abr. de 2014
I'm trying to change a value in a Simulink from my code using the set_param function. I'm using a very simple code:
modelName = 'Simple_Model';
open(modelName)
set_param(modelName,'SimulationCommand','start'); % Start the model
for i=1:1:10,
set_param([modelName '/Constant'],'value',num2str(i)); % Change the value
tic, while toc<1, end; % Wait 1s
end
set_param(modelName,'SimulationCommand','stop');
The simulations simply pushes the constant value to workspace variable. However, the simulation ends with no errors but doesn't return any value. I've found out that when I change the delay line from
tic, while toc<1, end;
to
pause(1);
Which supposed to do the same, the simulation does return values into the workspace variable.
Am I missing something? Is there any function to "refresh" the simulation without using the pause function? My actual code require small-to-zero delay, so using the pause function is not an option.
(see code+model attached)

Respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by