How to Read and Reuse FMU Internal Variables in MATLAB/Simulink?

7 次查看(过去 30 天)
Hey everyone,
I'm working with FMUs (Functional Mock-up Units) in MATLAB/Simulink and I'm trying to figure out how to read systematically the internal variables at the end of a simulation and reuse them for another run. This would really speed up the startup phase of our simulations.
In my previous job, I had a script that did this – it accessed and stored the internal variables at steady state and then reused them at the start of a new simulation. Unfortunately, I don't have that script anymore. MathWorks support had provided the details of the API back then, but I can't seem to find it now.
Does anyone know:
  • Which API or functions are available to read FMU internal variables at the end of a simulation?
  • How to store these variables and reuse them in subsequent simulations?
  • Any example scripts or documentation that could help with this?
Thanks a lot for your help!

回答(1 个)

Epsilon
Epsilon 2025-5-15
Hi gmos,
The internal states of the FMU can be captured by Simulink if the option for "Enable FMUState capability" is selected during the export of the FMU. This option is available in the advanced section of the export dialogue box, or as an input parameter (EnableFMUState, on) for the exportToFMU function.
The get_param function can then be used to capture the internal states of the FMU during iterative simulation. Enabling "Fast Restart" in the Simulate section of the toolstrip can also help speed up subsequent iterations. This example might be helpful for your scenario: https://www.mathworks.com/help/slcompiler/ug/FMUState-for-ModelStates-FastRestart-Stepping.html
The internal variables for the model can alternatively be stored and exported in the FMU, but they are limited to what is logged in the original model and do not capture the full FMU state. The documentation on exporting FMUs with internal variables can be found here: https://www.mathworks.com/help/slcompiler/ug/export-fmu-with-internal-var.html
Hope it helps!

类别

Help CenterFile Exchange 中查找有关 RF Blockset Models for Transceivers 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by