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

1 vue (au cours des 30 derniers jours)
Atharva Bhomle
Atharva Bhomle le 17 Juil 2023
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?

Réponses (1)

Nathan Hardenberg
Nathan Hardenberg le 17 Juil 2023
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:

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by