Simulink.Solver.VariableStepSolver Class
R2026bNamespace: Simulink.Solver
Description
Simulink.Solver.VariableStepSolver is the base class for authoring
variable-step plugin solvers. Simulink® provides several built-in solvers that can simulate a wide range of systems.
However, the built-in solver integration algorithms are not necessarily ideal for all domains
and problems. Using the plugin solver interface, you can implement custom solver integration
algorithms for Simulink simulations.
At each time step in the simulation, a variable-step solver:
Integrates continuous states by solving an initial value problem (IVP).
In the first time step, the initial state defines the initial value for the IVP. The solver computes the state at the next time step, which becomes the initial value in the next time step.
Advances time by determining a step size that satisfies specified error tolerances and the maximum step size determined by the simulator.
The simulator determines the maximum step size based on the value of the Max step size configuration parameter and sample times in the simulated system. To ensure that the solver does not step past a hit time for a sample time in the model, the simulator might choose a maximum step size that is smaller than the value of the Max step size parameter.
To write a plugin solver, you define only the integration algorithm in the
step method. The Simulink environment provides solver services, such as zero-crossing detection. For more
information about Simulink solvers, see Choose a Solver.
To simulate a system using a plugin solver:
Save the class definition for the plugin solver in a location on the MATLAB® path or add the plugin solver location to the path.
Register the plugin solver using the
Simulink.Solver.registerfunction.Specify the Solver parameter as the name of the plugin solver.
To implement a fixed-step plugin solver, use the class.Simulink.Solver.FixedStepSolver
The Simulink.Solver.VariableStepSolver class is a handle class.
Properties
Methods
Examples
Limitations
Plugin solvers do not support:
Rapid accelerator simulation
Software-in-the-loop (SIL) and processor-in-the-loop (PIL) simulation
Deployment with Simulink Compiler™
Production code generation using Simulink Coder™ or Embedded Coder®
Version History
Introduced in R2026b