Odd behavior defining operating point as initial state
조회 수: 12 (최근 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!