Main Content

Change Perturbation Level of Blocks Perturbed During Linearization

Blocks that do not have preprogrammed analytic Jacobians linearize using numerical perturbation. You can modify the size of the state and input signal perturbation levels for your application.

Change Block Perturbation Level

This example shows how to change the perturbation level to the Magnetic Ball Plant block in the magball model. Changing the perturbation level changes the linearization results.

For this model, the state and input signal values are double-precision values. The default perturbation size for the state and input signals in this model is 10-5(1+|x|), where x is the operating point value of the perturbed state or input signal.

Open the model before changing the perturbation level.

open_system('magball')

Change the perturbation level of the states to 10-7(1+|x|), where x is the state value.

blockname = 'magball/Magnetic Ball Plant';
set_param(blockname,'StatePerturbationForJacobian','1e-7');

To change the perturbation level of the input signal for this block to 10-3(1+|x|), where x is the input signal value, first obtain the block port handles and get the handle to the input port value.

ph = get_param(blockname,'PortHandles');
p_in = ph.Inport(1);

Then, set the input port perturbation level.

set_param(p_in,'PerturbationForJacobian','1e-3');

To obtain the current perturbation level for block states, use the following code.

statePerturb = get_param(blockname,'StatePerturbationForJacobian');

To obtain the current perturbation level for block input signals, use the following code.

inputPerturb = get_param(p_in,'PerturbationForJacobian');

When the corresponding state or input signal perturbation level is at its default value, both statePerturb and inputPerturb are 'auto'.

Default Perturbation Levels

The default perturbation size for double-precision states and input signals is 10-5(1+|x|), where x is the operating point value of the perturbed state or input signal. For single-precision states and input signals, the default perturbation size is 0.005(1+|x|).

To restore the default perturbation level for block states, use the following code.

set_param(blockname,'StatePerturbationForJacobian','auto');

To restore the default perturbation level for block input signals, use the following code.

set_param(p_in,'PerturbationForJacobian','auto');

Perturbation Levels of Integer-Valued Blocks

A custom block that requires integer input ports for indexing might have linearization issues when the block does not support small perturbations in the input value. To fix the problem, try setting the perturbation level of such a block to zero, which sets the block linearization to a gain of 1.

See Also

Related Topics