Odd behavior defining operating point as initial state
5 次查看(过去 30 天)
显示 更早的评论
I found two ways to set an operating point as initial state of a Simscape simulation:
- https://www.mathworks.com/help/stateflow/ug/specify-initial-state-for-simulation.html
- https://www.mathworks.com/help/simscape/ug/using-operating-point-data-for-model-initialization.html
Approach 1 works perfectly on my model:
Save state at the end of this phase

Load previously saved state as initial state

However, Simulink Coder code generation seems to be not supported that way, I get this error during generation:
Specifying initial operating point is only supported for models in Normal or Accelerator or Rapid Accelerator mode, and for Model blocks in Normal or Accelerator mode.
Approach 2 support the code generation, but it doesn't work as I expected:
I created operation point object based on the logged simulation: op = simscape.op.create(simlog, 5.0)

Used op here, Configuration parameters/Simscape:

The result:

I would expect the same diagram/behavior here what is on the 2nd figure.
Can anyone explain Approach 2 result? Do I misuse the feature?
Alternatively is it possible to support code generation with Approach 1?
1 个评论
Yifeng Tang
2025-3-19
I can only guess without seeing the model. Does the model contains controller? If so, does the controller have states (like integrator, transfer function, state space, PID, etc.)? There is a chance that the controller initial state doesn't match what's needed to keep the physical system starting from the intended values.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Magnetic Elements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!