필터 지우기
필터 지우기

How to perform a block opeartion at particular time index in simulink?

조회 수: 1 (최근 30일)
Atharva Bhomle
Atharva Bhomle 2023년 7월 17일
답변: Nathan Hardenberg 2023년 7월 17일
I want to find optimum value ofa parameter at each time index. For that i want to perform 2500 iterations for every time index in simulink simulation. For eg. when the simulation starts and T=1 sec, this matlab function block will perform 2500 iterations and find optimal value for this particular T. Now, T=2 sec, matlab function block will again perform 2500 to find optmal value of parameter particularly for T=2 sec and so on.
How can I execute this in simulink?

답변 (1개)

Nathan Hardenberg
Nathan Hardenberg 2023년 7월 17일
Check out the "Enabled Subsystem". Put your MATLAB function in there and only enable it on your desired timesteps.
One way to do this is with another MATLAB function, that could look like the one below. The input t would be the output of a "Clock"-Block.
function y = fcn(t)
if t == 1.00 % one second
y = 1;
elseif t == 2.00 % two seconds
y = 1;
else
y = 0; % do not execute subsystem
end
end
If you do it like that please use a "Fixed-step" and an appropriate "fundamental sample time" so every desired timestep gets executed as a Simulation step. To have millisecond precision for example, use:

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by