Dynamically starting model instances in Simulink

3 Ansichten (letzte 30 Tage)
Thomas
Thomas am 12 Mär. 2025
Kommentiert: Jack am 12 Mär. 2025
I have a top-level model which is intended to call a variable number of instances of a lower-level 6DOF block and run each instance as part of a loop. I would like to be able to initialize each instance dynamically (i.e., have initial conditions depending on when it is started) and start it at an arbitrary time relative to the start of the top-level model.
What is the most straightforward way to accomplish this?
  1 Kommentar
Jack
Jack am 12 Mär. 2025

Simulink determines initial conditions at simulation startup, so you can’t simply update a 6DOF block’s initial state mid-run. One common workaround is to delay activating each instance until after the top-level model has computed its state. For example, you can encapsulate the 6DOF block in a Triggered or Enabled Subsystem. Then, once the desired initial conditions are calculated, you can update the block’s parameters (via workspace variables or callbacks) and enable the subsystem so that the 6DOF block initializes with those conditions. Alternatively, if you don’t require concurrent execution, you could run separate simulation instances (using the sim command in a MATLAB loop) where you pass in the computed initial conditions.

Follow me so you can message me anytime with future questions. If this helps, please accept the answer and upvote it as well.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jack
Jack am 12 Mär. 2025
Simulink’s structure is fixed at compile time, so you can’t spawn new model instances on the fly during a simulation. The typical approach is to include a fixed number of lower-level 6DOF blocks (or model references) in your top-level model and then enable each one as needed using triggers or enable blocks. You can parameterize the initial conditions of each instance (using workspace variables or mask parameters) so that when a block is enabled (via a Triggered or Enabled Subsystem) it starts with its own unique initial state and at its designated time. Alternatively, if you don’t need concurrent execution, you could run separate simulations (using the sim command in a MATLAB loop) with different start times and initial conditions.
Follow me so you can message me anytime with future questions. If this helps, please accept the answer and upvote it as well.
  1 Kommentar
Thomas
Thomas am 12 Mär. 2025
I would like to set the initial position of each 6DOF instance based on the state of the top-level model (that is, the initial conditions wouldn't be known before running the model). I've tried using the Initialize subsystem for this, but it looks like those parameters aren't editable in the same way as other ones are.
Is there a way to dynamically initialize a 6DOF block after model start?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Subsystems finden Sie in Help Center und File Exchange

Produkte


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by