Main Content

CheckParameters

Check the validity of a MATLAB S-Function's parameters

Required

No

Language

MATLAB®

Syntax

CheckParameters(s)

Arguments

s

Instance of Simulink.MSFcnRunTimeBlock class representing a Level-2 MATLAB S-Function block.

Description

Verifies new parameter settings whenever parameters change or are reevaluated during a simulation.

When a simulation is running, changes to S-function parameters can occur at any time during the simulation loop, that is, either at the start of a simulation step or during a simulation step. When the change occurs during a simulation step, the Simulink® engine calls this routine twice to handle the parameter change. The first call during the simulation step is used to verify that the parameters are correct. After verifying the new parameters, the simulation continues using the original parameter values until the next simulation step, at which time the new parameter values are used. Redundant calls are needed to maintain simulation consistency.

Note

You cannot access the work, state, input, output, and other vectors in this routine. Use this routine only to validate the parameters. Additional processing of the parameters should be done in ProcessParameters.

Examples

In a Level-2 MATLAB S-function, the setup method registers the CheckParameters method as follows

s.RegBlockMethod('CheckParameters', @CheckParam);

The local function CheckParam then verifies the S-function parameters. In this example, the function checks that the second parameter, an upper limit value, is greater than the first S-function parameter, a lower limit value.

function CheckParam(s)

% Check that upper limit is greater than lower limit
lowerLim = s.DialogPrm(1).Data;
upperLim = s.DialogPrm(2).Data;

if upperLim <= lowerLim,
   error('The upper limit must be greater than the lower limit.');
end

Version History

Introduced in R2012b