Changing block parameter from MATLAB code seems to need 'pause'?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programmatic Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!