Run Matlab FUNCTION at the end of Simulink simulation
50 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alberto Mora
el 30 de Mayo de 2020
Comentada: Alberto Mora
el 5 de Jun. de 2020
Hello,
in a simulink simulation I compute some signals.
At the end of the simulation, when the system reach the steady-state condition, I want to use the final value of such signals to create a custom 3D plot. To do that I already built a Matlab FUNCTION block.
I don't want to run such Matlab FUNCTION block during the simulation because the computational time grows so much, and moreover I am interested only in the final value (steady-state).
How can I run such "Matlab FUNCTION block" only at the end of the simulation?
Thanks and best regards
2 comentarios
Respuesta aceptada
Sai Sri Pathuri
el 30 de Mayo de 2020
You may use StopFcn callback in your model. Refer the following link for Model callbacks. Expand Model Simulation Callback Parameters in the below documentation for StopFcn.
7 comentarios
Sai Sri Pathuri
el 2 de Jun. de 2020
Okay, In order to avoid overwriting and plot only last time step data, you may try this.
In constant block you used for FlagEndSim, use constant value as
[zeros(lengthOfOutput-1);1]
and Sample time as below. This is to retain previous sample rate after conversion by buffer
stepSize*lengthOfOutput
After the constant block, use buffer with output buffer size of 1.
With these changes, you can plot the results of only last simulation.
This is an example I tried at my end. I used a StopTime of 10 and a variable solver. For this, the output is of length 51 and step size is 0.2 (obtained from tout)
So, I have used the following settings
% Constant value
[zeros(50);1]
% SampleTime
0.2*51
Más respuestas (0)
Ver también
Categorías
Más información sobre Sources 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!