Blocks that do not have preprogrammed analytic Jacobians linearize using numerical perturbation.
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.
The default perturbation size is 10-5(1+|x|), where x is the operating point value of the perturbed state or the input.
Open the model before changing the perturbation level.
To change the perturbation level of the states to , where x is the state value, type:
blockname='magball/Magnetic Ball Plant' set_param(blockname,'StatePerturbationForJacobian','1e-7')
To change the perturbation level of the input to , where x is the input signal value:
Open the system and get the block port handles.
sys = 'magball'; open_system(sys) blockname = 'magball/Magnetic Ball Plant'; ph = get_param(blockname,'PortHandles')
Get the handle to the inport value.
p_in = ph.Inport(1)
Set the inport perturbation level.
A custom block that requires integer input ports for indexing might have linearization issues when this block:
Does not support small perturbations in the input value
Accepts double-precision inputs
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).