Using Simulink Previous page   Next Page

Choosing a Solver Type

Simulink divides solvers into two types: fixed-step and variable-step. Both types of solvers compute the next simulation time as the sum of the current simulation time and a quantity known as the step size. With a fixed-step solver, the step size remains constant throughout the simulation. By contrast, with a variable-step solver, the step size can vary from step to step, depending on the model's dynamics. In particular, a variable-step solver reduces the step size when a model's states are changing rapidly to maintain accuracy and increases the step size when the system's states are changing slowly in order to avoid taking unnecessary steps. The Type control on the Simulink Solver configuration pane allows you to select either of these two types of solvers (see The Solver Pane).

The choice between the two types depends on how you plan to deploy your model and the model's dynamics. If you plan to generate code from your model and run the code on a real-time computer system, you should choose a fixed-step solver to simulate the model. This is because real-time computer systems operate at fixed-size signal sample rates. A variable-step solver may cause the simulation to miss error conditions that can occur on a real-time computer system.

If you do not plan to deploy your model as generated code, the choice between a variable-step and a fixed-step solver depends on the dynamics of your model. If your model's states change rapidly or contain discontinuities, a variable-step solver can shorten the time required to simulate your model significantly. This is because, for such a model, a variable-step solver can require fewer time steps than a fixed-step solver to achieve a comparable level of accuracy.

The following model illustrates how a variable-step solver can shorten simulation time for a multirate discrete model.

This model generates outputs at two different rates, every 0.5 second and every 0.75 second. To capture both outputs, the fixed-step solver must take a time step every 0.25 second (the fundamental sample time for the model).

By contrast, the variable-step solver need take a step only when the model actually generates an output.

This significantly reduces the number of time steps required to simulate the model.

The variable-step discrete solver uses zero-crossing detection (see Zero-Crossing Detection) to handle continuous signals. Simulink uses this solver by default if you specify a continuous solver and your model has no continuous states.


Previous page  Choosing a Solver Choosing a Fixed-Step Solver Next page

© 1994-2005 The MathWorks, Inc.