Main Content

dlinmod

Extract discrete-time linear state-space model around operating point

Description

[A,B,C,D] = dlinmod(mdl,Ts) computes the linear state-space model with sample time Ts of the discrete-time system represented in the model mdl by linearizing each block in a model one by one. Inport and Outport blocks in the model represent the system inputs and outputs. You can use the dlinmod function to linearize discrete systems, multirate systems, and hybrid systems that contain both discrete and continuous dynamics.

The block-by-block analytic algorithm uses preprogrammed analytic block Jacobians for most blocks, which typically results in more accurate linearization compared to the perturbation algorithm. The Simulink® Control Design™ documentation contains a list of blocks that have preprogrammed analytic Jacobians and a discussion of the block-by-block analytic algorithm for linearization.

The block-by-block analytical algorithm also allows for special treatment of problematic blocks such as the Transport Delay block and the Quantizer block.

Note

The linmod function provides only basic linearization capabilities. For full linearization functionality, use Simulink Control Design software. For more information, see Choose Linearization Tools (Simulink Control Design).

[A,B,C,D] = dlinmod(mdl,Ts,x,u) computes the linear state-space model of the discrete-time system represented in the model mdl at the operating point defined by the state values x and the input values u.

[A,B,C,D] = dlinmod(mdl,Ts,x,u,opts,-v5) computes the discrete linear state-space model of the system represented in the model mdl using the full model perturbation algorithm from version 5.3 and earlier with the options opts.

[A,B,C,D] = dlinmod(mdl,Ts,x,u,opts,xpert,upert,-v5) computes the discrete linear state-space model of the system represented in the model mdl using the full model perturbation algorithm with options opts, state perturbation values xpert, and input perturbation values upert.

[n,d] = dlinmod(___) returns the discrete linear model in transfer function form.

sys = dlinmod(___) returns a structure that contains the discrete linear model, state names, input and output names, and information about the operating point.

Input Arguments

collapse all

Name of model to linearize, specified as a string or a character vector.

Data Types: char | string

Model states of operating point at which to linearize model, specified as a structure or a vector. The operating point at which to linearize the model is specified as a combination of the model states and the input values.

To extract the state of the model as a structure, use the Simulink.BlockDiagram.getInitialState function. You can edit the values of the model states by modifying the values field of the signals substructure. For example, use these commands to access the values of the state of the model named mdl.

mdlState = Simulink.BlockDiagram.getInitialState("mdl");
stateVals = mdlState.signals.values;

You must use the structure format to specify the states for the operating point when:

  • The model is a model reference hierarchy.

  • The model has states that have different data types.

  • The model has states that have a data type other than double.

Input values of operating point at which to linearize model, specified as a vector. The operating point at which to linearize the model is specified as a combination of the model states and the input values.

Data Types: double

Sample time of discrete-time linearized model, specified as a scalar number, in units of seconds. The linearized model has an identical frequency and time response for constant input values at the sample time Ts when all of these conditions are met:

  • The model you linearize contains linear, multirate, discrete, and continuous blocks.

  • The sample time of the discrete-time linearized model Ts is an integer multiple of all sample times in the model you linearize.

  • The system you linearize is stable.

When the sample time of the linearized model is not an integer multiple of all the sample times in the model you linearize, the linearized model is generally a time-varying system that does not have a state-space representation.

A system is stable if:

  • The sample time of the discrete-time linearized model is greater than 0 (Ts > 0) and the eigenvalues of the linearized matrix A are within the unit circle.

  • The sample time of the discrete-time linearized model is equal to 0 (Ts = 0) and the eigenvalues of the linearized matrix A are in the left half plane.

When the system is unstable and the sample time Ts is not an integer multiple of the other sample times, the matrices A and B of the linearized state-space model might be complex. The eigenvalues of the linearized matrix A still provide a good indication of stability.

Linearization options, specified as a vector with the elements and values described in the table.

ElementValueDefault
opts(1)

Perturbation value of delta used to perturb the model states and inputs.

The linmod function uses the value you specify only when you use the v5 perturbation algorithm. When you use the default block-by-block linearization algorithm, the linmod function ignores the value you specify and always uses the default value of 1e-5.

1e-5
opts(2)Nonnegative time at which to evaluate blocks during linearization.0
opts(3)

Option to remove extra states from blocks that do not have direct feedthrough.

  • 0 — Do not remove extra states from blocks that do not have direct feedthrough.

  • 1 — Remove extra states from blocks that do not have direct feedthrough.

0

State perturbation values, specified as a structure or a vector. You must use the structure format to specify the state perturbation values when:

  • The model is a model reference hierarchy.

  • The model has states that have different data types.

  • The model has states that have a data type other than double.

To extract the model states as a structure, use the Simulink.BlockDiagram.getInitialState function. You can then edit the values in the structure to specify the perturbation value for each state by modifying the values field of the signals substructure. For example, use these commands to access the states of the model named mdl.

mdlState = Simulink.BlockDiagram.getInitialState("mdl");
stateVals = mdlState.signals.values;

You can specify state and input perturbation values only when you linearize the model using the perturbation algorithm from versions 5.3 and earlier by calling the linmodv5 function or by specifying the -v5 input option.

By default, the perturbation values are calculated using the delta value specified in the first element of the opts input vector as shown in this code.

xpert = opts(1) + 1e-3*opts(1)*abs(x);

Input perturbation values, specified as a structure or a vector.

You can specify state and input perturbation values only when you linearize the model using the perturbation algorithm from versions 5.3 and earlier by calling the linmodv5 function or by specifying the -v5 input option.

By default, the perturbation values are calculated using the delta value specified in the first element of the opts input vector as shown in this code.

upert = opts(1) + 1e-3*opts(1)*abs(u);

Output Arguments

collapse all

State-space representation of linearized model, returned as a vector.

Transfer function representation of linearized model, returned as a vector.

Linearized model, returned as a structure that contains state names, input and output names, and information about the operating point.

Limitations

  • The linmod function provides only basic linearization capabilities. For full linearization functionality, use Simulink Control Design software. For more information, see Choose Linearization Tools (Simulink Control Design).

  • When you linearize a model reference hierarchy, configure the top and referenced models to simulate in normal mode. Multiple limitations exist for linearizing multirate referenced models that simulate in accelerator mode.

  • When you linearize a model reference hierarchy that contains referenced models configured to simulate in accelerator mode, the software uses the default algorithm to linearize the top model and the numeric perturbation algorithm to linearize the referenced model.

  • Linearization is not supported for models that contain one or more referenced models configured to use a local solver. For more information, see Use Local Solvers in Referenced Models.

Tips

  • You can use the dlinmod function to convert a system to a different sample time, including converting a discrete system to a continuous system and vice versa.

  • To find the frequency response of a discrete or continuous system, use the bode function.

  • By default, the system time is zero. For systems that are dependent on time, you can specify the system time using the second element of the opts input argument.

  • State order is maintained in linearization such that the order of states in the linearized model matches the order of states in the nonlinear model. You can get information about the states in a model and the blocks associated with the states by using the model name as a programmatic interface to execute the sizes phase. The return argument named blks is a vector that contains the name of each block associated with a state. For more information, see Use Model Name as Programmatic Interface.

    [sys,x0,blks,st] = modelName([],[],[],'sizes');
  • You can convert the state-space linearized representation of a linearized single-input, multiple-output system to another form using these functions:

    • ss2tf — Convert from state-space to transfer function form.

    • ss2zp (Signal Processing Toolbox) — Convert from state-space to zero-pole form.

  • You can create a state-space model object from a linearized model using the ss (Control System Toolbox) function. You can use state-space model objects to represent a linear time invariant (LTI) system for control design. You can also combine multiple LTI state-space models to represent more complex systems.

  • After creating a state-space model object, you can convert to transfer function form using the tf (Control System Toolbox) function or convert to zero-pole-gain form using the zpk (Control System Toolbox) function.

  • The default block-by-block algorithm is recommended for linearizing models that contain Transport Delay or Derivative blocks. The block-by-block algorithm replaces Transport Delay and Derivative blocks with Pade approximations. Using the v5 perturbation algorithm to linearize models that contain Transport Delay or Derivative blocks can be troublesome. For more information, see Linearizing Models.

  • Before linearizing a model that contains Transport Delay or Derivative blocks using the v5 perturbation algorithm, replace the Transport Delay and Derivative blocks with the specialized blocks available in the Linearization library inside the Simulink Extras library.

Version History

Introduced in R2007a

See Also

| |