Error with FixedStepDiscrete Solver in Simscape Plant Model During Code Generation Attempt

11 次查看(过去 30 天)
I'm working on generating C/C++ code from a Simulink plant model that uses Simscape blocks, specifically for an EV plant model project. As a starting point, I've created a minimal test model ('Test') containing just a single Simscape block (e.g., a basic electrical or mechanical component) with no other blocks or connections.
When I try to build the model for code generation (using ert.tlc or similar), it automatically selects the "FixedStepDiscrete" solver and fails with this error:
text
Error: The "FixedStepDiscrete" solver cannot be used to simulate block diagram 'Test' because it contains continuous states.
I understand this happens because Simscape blocks introduce continuous states, which require a continuous or fixed-step continuous solver (like ode4 or auto-detected fixed-step). However, for code generation with Simulink Coder, documentation indicates fixed-step solvers are often required, and purely discrete solvers don't support continuous states​
My questions:
  1. Is code generation possible from a plant model with Simscape blocks? If yes, what solver configuration works (e.g., fixed-step continuous solver with specific settings)?
  2. For a simple model with one block, how do I configure the solver and model settings to enable successful code generation? Should I add a Solver Configuration block or use a local solver?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Electromagnetic Models 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by