Error with FixedStepDiscrete Solver in Simscape Plant Model During Code Generation Attempt
11 views (last 30 days)
Show older comments
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:
- 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)?
- 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?
1 Comment
Tridib
5 minutes ago
Please refer to the following documentations which should assist you in resolving your doubts:
Hope this helps!
Answers (0)
See Also
Categories
Find more on Electromagnetic Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!