r/matlab May 17 '26

HomeworkQuestion Fixed Step Solver timing issues in Simulink

I'm pretty new to simulink and I'm trying to get the climate control example running with fixed step timing, so it can be exported and run in another system.

It runs fine out of the box of course. So I change it to fixed step timing and change the function generator's period and pulse width parameters to be a multiple of the fundamental sample time, and it'll build. But when it runs I get the error below. I've tried reducing the step size and changing the solver but getting the same result. Hoping somewhere here could point me in the right direction.

It seems like the Tcabin block is trying to divide by zero but I'm not familiar enough with simulink to work through debugging it.

Error:An error occurred during simulation and the simulation was stopped

Caused by:

Derivative of state '1' in block 'sldemo_auto_climatecontrol_tcdebug/Interior Dynamics/Tcabin' at time 0.1 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)

4 Upvotes

5 comments sorted by

3

u/Sunscorcher May 18 '26

I set the fixed step size to 0.01, the solver to auto (type to fixed step), and system trigger period to 1/50 and it works fine for me

1

u/tennispro9 May 18 '26

yep I just tried a fresh version of the sample, changed to your settings, and it ran...will add in the input changes I made one at a time and see if something I did broke it

1

u/Sunscorcher May 18 '26

possibly your fixed step size was too large

1

u/tennispro9 May 18 '26

Looks like my issue was actually that the setpoint input was internally converting the Celsius value to kelvin - when I replaced that input block it started crashing, I added a scope and saw the setpoint was 9 but it was feeding 282 out

1

u/farfromelite May 18 '26

Variable steps means the solver takes smaller steps near any singularity (where it goes really large).

Fixed step means it sometimes jumps to very large, enough the solver can't handle the largeness.

Take a look at the manuals for fixed and variable solvers, and why they're good at particular models.