Main Content

Samples to Export for Variable-Step Solvers

Output Options

Use the Output options list under Configuration Parameters > Data Import/Export > Additional parameters to control how much output the simulation generates when your model uses a variable-step solver.

  • Refine output (default)

  • Produce additional output

  • Produce specified output only

Refine Output

The Refine output option provides additional output points when the simulation output does not include as many points as you would like. This parameter provides an integer number of output points between time steps. For example, a refine factor of 2 provides output midway between the time steps and at the steps. The default refine factor is 1.

Suppose that a sample simulation generates output at these times:

0, 2.5, 5, 8.5, 10

Choosing Refine output and specifying a refine factor of 2 generates output at these times:

0, 1.25, 2.5, 3.75, 5, 6.75, 8.5, 9.25, 10

To get smoother output more efficiently, change the refine factor instead of reducing the step size. When you change the refine factor, the solver generates additional points by evaluating a continuous extension formula at sample points. This option changes the simulation step size so that time steps coincide with the times that you specify for additional output.

The refine factor applies to variable-step solvers and is most useful when you are using ode45. The ode45 solver can take large steps. However, when you graph simulation output, the output from this solver sometimes is not sufficiently smooth. In such cases, run the simulation again with a larger refine factor. A value of such as 4 for ode45 can provide much smoother results.

Note

This option helps the solver locate zero crossings, although it does not ensure that Simulink® detects all zero crossings (see Zero-Crossing Detection).

Produce Additional Output

Use the Produce additional output option to specify directly those additional times at which the solver generates output. When you select this option, the Data Import/Export pane displays an Output times configuration parameter. In this parameter, enter a MATLAB® expression that evaluates to an additional time or a vector of additional times. The solver produces hit times at the output times that you specify, in addition to the times it requires for accurate simulation.

Suppose that a sample simulation generates output at these times:

0, 2.5, 5, 8.5, 10

Choosing the Produce additional output option and specifying [0:10] generates output at these times:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

and perhaps at additional times, depending on the step size chosen by the variable-step solver.

Tips

  • This option helps the solver locate zero crossings, although it does not ensure that Simulink detects all zero crossings (see Zero-Crossing Detection).

  • Set the Output times configuration parameter to a value other than the default empty matrix ([]).

  • For triggered subsystems and function-call subsystems, the calling function must inherit the sampling rate.

Produce Specified Output Only

Simulink generates output at the start and stop times, in addition to the times that you specify.

Suppose that a sample simulation generates output at these times:

0, 2.5, 5, 8.5, 10

Choosing the Produce specified output only option and specifying [1:9] generates output at these times:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

This option changes the simulation step size so that time steps coincide with the times that you specify for producing output. The solver can hit other time steps to accurately simulate the model. However, the output does not include these points. This option is useful when you are comparing different simulations to check that the simulations produce output at the same times.

Tips

  • This option helps the solver locate zero crossings, although it does not ensure that Simulink detects all zero crossings (see Zero-Crossing Detection).

  • Set the Output times configuration parameter to a value other than the default empty matrix ([]).

  • In normal, accelerator, and rapid accelerator modes, Simulink generates output at the start and stop times, as well as at the times that you specify.

  • When you simulate a model in normal mode, triggered subsystems and function-call subsystems use:

    • The times that you specify

    • All the time steps in between the values that you specify

    • The simulation start and stop times

  • For triggered subsystems and function-call subsystems, the calling function must inherit the sampling rate.

Related Examples

More About