Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
Nitzan
Nitzan am 24 Apr. 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)

Antworten (0)

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by