Simulink.o​p.ModelOpe​ratingPoin​t - Remove "snapshotTime"

조회 수: 36 (최근 30일)
Trent
Trent 2026년 2월 11일 21:30
답변: Trent 2026년 2월 12일 14:53
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?
  댓글 수: 1
Trent
Trent 2026년 2월 11일 22:21
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Trent
Trent 2026년 2월 12일 14:53
In the Simulink "Model Configuration Parameters" under "Data Import/Export/Save to workspace or file", select only "Final states". Do not check the "Save final operating point" check box. Now, subsequent model runs will be able to initialize from out.xFinal, or whatever you've named your Final States.
What I still do not understand is why the values of out.xFinal.loggedStates when using "Save final operating point" are somehow different than the values of out.xFinal when not using "Save final operating point". It appears to be the same data, but the former does not work to initialize the model.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Troubleshooting에 대해 자세히 알아보기

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by