1

(This question is similar to previous question I have posted, but the situation has changed...)

I am using the Modelon FMI toolbox for a Dymola/Simulink interface to import a Model-Exchange type fmu file (version 1.0) into the Simulink model. I have a Matlab m-file that programmatically simulates the model sequentially, saving the final internal states of the model for initialization in the next simulation.

The simulation call in the m-file is:

simOut_itr = sim(model, model_cs);

Where “model” is the Simulink .slx model file and “model_cs” is a Simulink Configuration Setting variable. I have set the Configuration such that the model loads initial states from the workspace, and I have saved the previous iterations final states to that workspace variable.

However, when I run my code, the initialization values do not set in the model, and the results of the simulation show that the model outputs reset to their initial values each time the simulation is run. This behavior indicates to me that the states are not initializing using the workspace variable values, but no error is set during the simulation. I have confirmed that loading and unloading the model for each iteration does not help.

Any suggestions with regard to initializing the system states in fmu files in Matlab/Simulink are much appreciated. Thank you.

E Heller
  • 13
  • 1
  • 6

2 Answers2

0

The FMI toolbox block in Simulink does not set it's initialization values from the call to the model (sim), but rather from a separate set of functions specific to the FMI toolbox. The FMI toolbox manual has more details.

E Heller
  • 13
  • 1
  • 6
0

fmuSetValueSimulink() is the function to use. This is used to set both parameter values and start values for state variables. The help section for the function is quite informative so I won't go into detail here.