Use of set_param inside an embedded Matlab function: delay observed

Hello,
I want to modify the value of a gain during simulation using the simple enclosed simulink model and including the following Matlab function (previously EML).
function ChangeParam(time)
coder.extrinsic('set_param');
coder.extrinsic('num2str');
if time == 10,
set_param('untitled1/Constant','Value',num2str(1));
end
Modification occurs but at time t=11 sec (sample time = 1sec) whereas I would like the modification to occur at time = 10 sec.
Is there a way to ensure that modification occurs at the current cycle? Is there a way to ensure that the Matlab function runs before the computation that uses the constant block?
Regards,

Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Products

Asked:

on 2 Mar 2016

Community Treasure Hunt

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

Start Hunting!