How to perform a block opeartion at particular time index in simulink?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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?
0 comentarios
Respuestas (1)
Nathan Hardenberg
el 17 de Jul. de 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:
0 comentarios
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!