Main Content

compreal

Compute companion state-space realization

Since R2023b

    Description

    example

    csys = compreal(sys) returns the controllable companion realization of the single-input LTI model sys.

    example

    csys = compreal(sys,type) returns the realization of the model sys depending on type. Specify type as "c" for controllable companion form or "o" for observable companion form.

    • "c" — Computes the controllable companion realization for a single-input LTI model sys. This is the same as the first syntax.

    • "o" — Computes the observable companion realization for a single-output LTI model sys.

    example

    [csys,T] = compreal(___) also returns the transformation matrix T for explicit models with matrices A, B, C such that

    • The controllable companion form is T-1AT, T-1B, CT.

    • The observable companion form is TAT-1, TB, CT-1.

    Examples

    collapse all

    aircraftPitchSSModel.mat contains the state-space matrices of an aircraft where the input is elevator deflection angle δ and the output is the aircraft pitch angle θ.

    [α˙q˙θ˙]=[-0.31356.70-0.0139-0.4260056.70][αqθ]+[0.2320.02030][δ]y=[001][αqθ]+[0][δ]

    Load the model data to the workspace and create the state-space model sys.

    load('aircraftPitchSSModel.mat');
    sys = ss(A,B,C,D)
    sys =
     
      A = 
                x1       x2       x3
       x1   -0.313     56.7        0
       x2  -0.0139   -0.426        0
       x3        0     56.7        0
     
      B = 
               u1
       x1   0.232
       x2  0.0203
       x3       0
     
      C = 
           x1  x2  x3
       y1   0   0   1
     
      D = 
           u1
       y1   0
     
    Continuous-time state-space model.
    

    Convert the resultant state-space model sys to controllable companion form.

    csys = compreal(sys)
    csys =
     
      A = 
                  x1         x2         x3
       x1          0          0  1.914e-15
       x2          1          0    -0.9215
       x3          0          1     -0.739
     
      B = 
           u1
       x1   1
       x2   0
       x3   0
     
      C = 
                x1       x2       x3
       y1        0    1.151  -0.6732
     
      D = 
           u1
       y1   0
     
    Continuous-time state-space model.
    

    csys is the controllable companion form of sys.

    The file icEngine.mat contains one data set with 1500 input-output samples collected at the a sampling rate of 0.04 seconds. The input u(t) is the voltage (V) controlling the By-Pass Idle Air Valve (BPAV), and the output y(t) is the engine speed (RPM/100).

    Use the data in icEngine.mat to create a state-space model with identifiable parameters.

    load icEngine.mat
    z = iddata(y,u,0.04);
    sys = n4sid(z,4,'InputDelay',2);

    Convert the identified state-space model sys to observable companion form.

    [osys,T] = compreal(sys,"o");

    Compare frequency response confidence bounds of sys to osys.

    h = bodeplot(sys,osys,'r.');
    showConfidence(h)

    Figure contains 2 axes objects. Axes object 1 with title From: u1 To: y1, ylabel Magnitude (dB) contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent sys, osys. Axes object 2 with ylabel Phase (deg) contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent sys, osys.

    The frequency response confidence bounds are identical.

    Additionally, compreal returns a transformation matrix T such that the observable companion form is Ao=TAT-1, Bo=TB, Co=CT-1.

    Input Arguments

    collapse all

    Dynamic system, specified as a SISO, or MIMO dynamic system model. Dynamic systems that you can use include:

    • Continuous-time or discrete-time numeric LTI models, such as tf (Control System Toolbox), zpk (Control System Toolbox), ss (Control System Toolbox), or pid (Control System Toolbox) models.

    • Generalized or uncertain LTI models such as genss (Control System Toolbox) or uss (Robust Control Toolbox) models. (Using uncertain models requires Robust Control Toolbox™ software.)

    • Identified LTI models, such as idtf, idss, idproc, idpoly, and idgrey models.

    You cannot use frequency-response data models such as frd (Control System Toolbox) models.

    Companion realization type, specified as "c" (controllable companion form) or "o" (observable companion form).

    For a system with characteristic polynomial

    P(s)=sn+αn1sn1+αn2sn2++α1s+α0,

    the function returns the companion forms as follows.

    • Controllable Companion Form

      In the controllable companion realization, the characteristic polynomial of the system appears explicitly in the rightmost column of the A matrix.

      Accom=[01000001000001000001α0α1α2α3  αn1],Bccom=[100].

    • Observable Companion Form

      In the observable companion realization, the characteristic polynomial of the system appears explicitly in the last row of the A matrix.

      Aocom=[0000α01000α10100α20010α30001αn1],Cocom=[100].

    For more information, see State-Space Realizations.

    Output Arguments

    collapse all

    Companion state-space form of the dynamic model, returned as an ss (Control System Toolbox) model object. csys is a state-space realization of sys in the companion form specified by type (controllable or observable).

    Transformation matrix, returned as an n-by-n matrix, where n is the number of states.

    • For explicit state-space models with matrices A, B, C, the function returns T such that

      • The controllable companion form is T-1AT, T-1B, CT.

      • The observable companion form is TAT-1, TB, CT-1.

    • For descriptor state-space models, the function always returns an empty value [].

    Tips

    Computing companion realizations often involves ill-conditioned transformations and loss of accuracy. Use modalreal or balreal as numerically stable alternatives.

    Version History

    Introduced in R2023b

    See Also

    | (Control System Toolbox) | (Control System Toolbox) | (Control System Toolbox) | (Control System Toolbox) | (Control System Toolbox)