Simulink - Times

3 visualizaciones (últimos 30 días)
JOKY JOKE
JOKY JOKE el 15 de Nov. de 2011
Hi,
is there a command which gives me the simulation time (not the real time) of my simulink simulation when I stop it manually? I would only need it at the end of the simulation in Matlab.
I am using callback functions and I can get the total simulation time by t_sim = str2num(get_param('model','StopTime')) However, this time does not depend on when I stop the simulation manually.
I would need a command which gives me the actual simulation time and I could implement it as a callback StopFcn.
Thank you

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 15 de Nov. de 2011
There are two ways.
If you are using sim() to run the simulation, then use [T,X,Y]= sim('model',TIMESPAN,OPTIONS,UT), T(end) will be the stop time that you need.
In the Data Import/Export portion of the Configuration Parameters dialog, check the "Time" option, the time vector will be saved to the variable "tout" in the workspace. When you manually stop the simulation, tout(end) will be the stop time.
Another way is to manually "pause" the simulation, instead of stop the simulation. You'll see the pause time at the status bar (the bar at the bottom of your model window). Then you can stop the simulation.
Or you can put a "Clock" block (in Source library) and a "Display" block (in Sinks library) at the root level of your model. When you stop the simulation, the "Display" block will show the actual stop time.

Más respuestas (1)

JOKY JOKE
JOKY JOKE el 1 de Dic. de 2011
HI,
thank you, works wonderfully! The tout ist of size 1000. Is there a way to change the size of the vector that is written to the workspace?
Thank you
  1 comentario
Fangjun Jiang
Fangjun Jiang el 1 de Dic. de 2011
No. You can't change the size of the data log. It is dependent on your step size and simulation time. See update in the answer for other solution.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by