Since posting, I have also attempted to use the states from the Simulink model by checking States and saving this to out.xout. This appears to be even worse than the above methods as it seems like every single simscape state fails to be set.
Simulink.op.ModelOperatingPoint - Remove "snapshotTime"
36 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Trent
il 11 Feb 2026 alle 21:30
I have created a Simulink model which contains a Simscape Physical Network. Both my Simscape Physical Network and Simulink components have states which I want to set at the initiation of my simulation.
Per this documentation, ( https://www.mathworks.com/help/simulink/ug/model-operating-point-for-faster-simulation.html ), it seems I need a Simulink.op.ModelOperatingPoint object. I have created this by running my model for 10 seconds with "Final States" and "Save final operating point" enabled. Doing this, I was able to create my object which correctly initializes my model.
ISSUE:
With a Simulink.op.ModelOperatingPoint, I must now bookkeep an additional 10 seconds on the 'Stop Time' of every model run I complete. I do not care about the initial 10 seconds of simulation. I am not "resuming" my simulation from this operating point. This data is simply the model settling on point from poor initial conditions set on the block diagram. I want t=0 of my simulation to be initialized at this operating point with any semblance of time completely discarded. If I cannot discard time, I now need to add 10 seconds to all of my simulations. Even worse, if I use this operating point to create a new operating point,the start time will continue to increase. I also need to bookkeep this time in my Simulink.SimulationData.Dataset used as externalInput, as if I start my new experiment at t=0 (rather than t=10), this simulation information will be missed.
ATTEMPTED SOLUTION:
Of the states saved in out.xFinal, all of the state information appears to be in out.xFinal.loggedStates. I have attempted to use this directly as my operating point. When setting my initial condition to out.xFinal.loggedStates (rather than out.xFinal directly), I recieve an error that some, but not all, of my simscape states are unable to be set. Below is the error recieved:
Cannot load initial state for model 'myModelName'
Caused by:
Cannot restore the state value of the block 'myModelName/path/to/block'.
Cannot restore the state value of the block 'myModelName/path/to/block'.
Cannot restore the state value of the block 'myModelName/path/to/block'.
Cannot restore the state value of the block 'myModelName/path/to/block'.
Cannot restore the state value of the block 'myModelName/path/to/block'.
Cannot restore the state value of the block 'myModelName/path/to/block'.
Cannot restore the state value of the block 'myModelName/path/to/block'.
Each of the above blocks that cannot be restored are simscape blocks, but they are not all of the simscape blocks in the model. Additionally, when manually inspecting out.xFinal.loggedStates, I am able to find all of the state information for each of these blocks.
It seems like my other options are an opcond.OperatingPoint or a simscape.op.OperatingPoint. A simscape.op.OperatingPoint will not work as it is not capable of managing simulink state information. When I use an opcond.OperatingPoint, I recieve the error:
Loading initial states for model 'myModelName' from the MATLAB object specified in Initial state is not supported. To specify the initial state, use a non-empty scalar object of type Simulink.op.ModelOperatingPoint or Simulink.SimulationData.Dataset.
The above error is extra confusing because out.xFinal.loggedStates is a "Simulink.SimulationData.Dataset" object, yet that will not initialize my model either. And if not to initialize my model, what is an opcond.OperatingPoint for?
What is the intended workflow for creation an operating point for models which contain Simulink and Simscape states that does not impact the Start Time / Stop Time parameters of the Simulink model?
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Troubleshooting in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!