Running Simulink model in a loop

2 visualizaciones (últimos 30 días)
A Afonja
A Afonja el 24 de Abr. de 2019
Respondida: A Afonja el 24 de Abr. de 2019
I want to run a simulink model in a loop and store the output for analysis.
However, I noticed that it is the result of the last calculation that gets stored.
Below is my syntax
Period=2:2:10;
Omega=2*pi./Period;
tauDot=0.05473;
simutime=100;
for i=length(Omega);
omega=Omega(i);
sim('PTO_model',simutime);
Pr=simout;
Pressure(:,i)=Pr;
end
omega and taudot are variables defined to be used in the model.
simout is an output to workspace block that I have withing my simulink model.
The issue is that the final result of Pressure is a matrix with the first 4 columns having all zeros and the last coulmn containing results fof the last pass of the for loop.
Could anyone tell me why the reults of the first 4 calculations is not saved.

Respuesta aceptada

Yasasvi Harish Kumar
Yasasvi Harish Kumar el 24 de Abr. de 2019
Hi,
You can use data store memory block and log the value in the workspace as well. Read more here.
Regards

Más respuestas (1)

A Afonja
A Afonja el 24 de Abr. de 2019
I have found where the problem is. Very basic mistake. I wrote i=length(omega) and not i=1:length(omega).
Thanks for responding Yasasvi

Categorías

Más información sobre Model, Block, and Port Callbacks en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by