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,

답변 (0개)

카테고리

도움말 센터File Exchange에서 Simulink에 대해 자세히 알아보기

질문:

2016년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by