Main Content

Augment the Linearization of a Block

This example shows how to augment the linearization of a block with additional time delay dynamics, using a block linearization specification function.

  1. Open Simulink® model.

    mdl = 'scdFcnCall';
    open_system(mdl)

    This model includes a continuous time plant, Plant, and a discrete-time controller, Controller. The D/A block discretizes the plant output with a sampling time of 0.1 s. The External Scheduler block triggers the controller to execute with the same period, 0.1 s. However, the trigger has an offset of 0.05 s relative to the discretized plant output. For that reason, the controller does not process a change in the reference signal until 0.05 s after the change occurs. This offset introduces a time delay of 0.05 s into the model.

  2. (Optional) Linearize the closed-loop model at the model operating point without specifying a linearization for the Controller block.

    io = getlinio(mdl);
    sys_nd = linearize(mdl,io);
    

    The getlinio function returns the linearization input and output points that are already defined in the model.

  3. (Optional) Check the linearization result by frequency response estimation.

    input = frest.Sinestream(sys_nd);
    sysest = frestimate(mdl,io,input);
    bode(sys_nd,'g',sysest,'r*',{input.Frequency(1),input.Frequency(end)})
    legend('Linearization without delay',...
         'Frequency Response Estimation','Location','SouthWest')
    

    The exact linearization does not account for the time delay introduced by the controller execution offset. A discrepancy results between the linearized model and the estimated model, especially at higher frequencies.

  4. Write a function to specify the linearization of the Controller block that includes the time delay.

    The following configuration function defines a linear system that equals the default block linearization multiplied by a time delay. Save this configuration function to a location on your MATLAB® path. (For this example, the function is already saved as scdAddDelayFcn.m.)

    function sys = scdAddDelayFcn(BlockData)
    sys = BlockData.BlockLinearization*thiran(0.05,0.1);

    The input to the function, BlockData, is a structure that the software creates automatically each time it linearizes the block. When you specify a block linearization configuration function, the software automatically passes BlockData to the function. The field BlockData.BlockLinearization contains the current linearization of the block.

    This configuration function approximates the time delay as a thiran filter. The filter indicates a discrete-time approximation of the fractional time delay of 0.5 sampling periods. (The 0.05 s delay has a sampling time of 0.1 s).

  5. Specify the configuration function scdAddDelayFcn as the linearization for the Controller block.

    1. Right-click the Controller block, and select Linear Analysis > Specify Selected Block Linearization.

    2. Select the Specify block linearization using one of the following check box. Then, select Configuration Function from the drop-down list.

    3. Enter the function name scdAddDelayFcn in the text box. scdAddDelayFcn has no parameters, so leave the parameter table blank.

    4. Click OK.

  6. Linearize the model using the specified block linearization.

    sys_d = linearize(mdl,io);
    

    The linear model sys_d is a linearization of the closed-loop model that accounts for the time delay.

  7. (Optional) Compare the linearization that includes the delay with the estimated frequency response.

    bode(sys_d,'b',sys_nd,'g',sysest,'r*',...
         {input.Frequency(1),input.Frequency(end)})
    legend('Linearization with delay','Linearization without delay',...
         'Frequency Response Estimation','Location','SouthWest')

    The linear model obtained with the specified block linearization now accounts for the time delay. This linear model is therefore a much better match to the real frequency response of the Simulink model.

See Also

|