In Simulink, Matlab Function, how to save a variable at the end of the simulation?

3 visualizaciones (últimos 30 días)
I have a Matlab Function in Simulink. In the Function there is a persistent matrix (M).
When the Simulation is stopped/finished, I want to have access to matrix M.

Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 23 de Abr. de 2013
I think the only way to have access to internal data of a MATLAB Function block is to create an output to the function and assign the output to the value of the persistent variable.
  2 comentarios
yosey
yosey el 23 de Abr. de 2013
Thanks for your answer, helps me alot. Next I need to get M out of Simulink, when the simulation is stopped or finished.
The only solution that I know, is the 'Stop Simulation'-Block with a logical query. If the stop-simulation-flag is true, a triggered 'To File' or 'To Workspace' saves M.
But, the simulation can't be stopped manually anymore with the intended button.
I guess its not possible to do the job in the StopFcn-Callback?
yosey
yosey el 26 de Abr. de 2013
Editada: yosey el 27 de Abr. de 2013
The 'To Workspace' block has an option 'Limit data points to last'. I put the option to 1 and thats working for me.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by