フィルターのクリア

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

2 ビュー (過去 30 日間)
Nitzan
Nitzan 2014 年 4 月 24 日
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)

回答 (0 件)

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by