clase 1 - control en matlab

Upload: eric-mosvel

Post on 30-May-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 Clase 1 - Control en Matlab

    1/10

    1

    CONTROL 2

    Uso del Matlab

    Considere el siguiente sistema:

    u

    x

    x

    x

    x

    x

    x

    +

    =

    1

    0

    0

    6116

    100

    010

    3

    2

    1

    3

    2

    1

    &

    &

    &

    [ ]

    =

    3

    2

    1

    111

    x

    x

    x

    y

    Lo primero es digitar las matrices en Matlab

    a=[0,1,0;0,0,1;-6,-11,-6]

    a =

    0 1 00 0 1

    -6 -11 -6

    b=[0;0;1]

    b =00

    1

    c=[1,1,1]

    c =1 1 1

  • 8/14/2019 Clase 1 - Control en Matlab

    2/10

    2

    d=[0]

    d =0

    Con el comando eig se pueden encontrar los autovalores y los autovectores

    help eig

    EIG Eigenvalues and eigenvectors.E = EIG(X) is a vector containing the eigenvalues of a squarematrix X.

    [V,D] = EIG(X) produces a diagonal matrix D of eigenvalues and a

    full matrix V whose columns are the corresponding eigenvectors sothat X*V = V*D.

    [V,D] = EIG(X,'nobalance') performs the computation with balancingdisabled, which sometimes gives more accurate results for certainproblems with unusual scaling.

    E = EIG(A,B) is a vector containing the generalized eigenvaluesof square matrices A and B.

    [V,D] = EIG(A,B) produces a diagonal matrix D of generalizedeigenvalues and a full matrix V whose columns are thecorresponding eigenvectors so that A*V = B*V*D.

    See also CONDEIG, EIGS.

    Overloaded methodshelp sym/eig.mhelp lti/eig.m

    eig(a)

    ans =-1.0000-2.0000-3.0000

  • 8/14/2019 Clase 1 - Control en Matlab

    3/10

    3

    [m,ed]=eig(a)

    m =-0.5774 0.2182 -0.10480.5774 -0.4364 0.3145-0.5774 0.8729 -0.9435

    ed =-1.0000 0 0

    0 -2.0000 00 0 -3.0000

    Se observa la matriz modal m y en la matriz ed los polos en la diagonalprincipal.

    Ahora se usa la orden ss

    help ss

    SS Create state-space model or convert LTI model to state space.

    Creation:SYS = SS(A,B,C,D) creates a continuous-time state-space (SS) modelSYS with matrices A,B,C,D. The output SYS is a SS object. Youcan set D=0 to mean the zero matrix of appropriate dimensions.

    SYS = SS(A,B,C,D,Ts) creates a discrete-time SS model with sampletime Ts (set Ts=-1 if the sample time is undetermined).

    SYS = SS creates an empty SS object.SYS = SS(D) specifies a static gain matrix D.

    In all syntax above, the input list can be followed by pairs'PropertyName1', PropertyValue1, ...

    that set the various properties of SS models (type LTIPROPS for

    details). To make SYS inherit all its LTI properties from anexisting LTI model REFSYS, use the syntax SYS = SS(A,B,C,D,REFSYS).

    Arrays of state-space models:You can create arrays of state-space models by using ND arrays forA,B,C,D above. The first two dimensions of A,B,C,D determine thenumber of states, inputs, and outputs, while the remaining

  • 8/14/2019 Clase 1 - Control en Matlab

    4/10

    4

    dimensions specify the array sizes. For example, if A,B,C,D are4D arrays and their last two dimensions have lengths 2 and 5, then

    SYS = SS(A,B,C,D)creates the 2-by-5 array of SS models

    SYS(:,:,k,m) = SS(A(:,:,k,m),...,D(:,:,k,m)), k=1:2, m=1:5.All models in the resulting SS array share the same number ofoutputs, inputs, and states.

    SYS = SS(ZEROS([NY NU S1...Sk])) pre-allocates space for an SS arraywith NY outputs, NU inputs, and array sizes [S1...Sk].

    Conversion:SYS = SS(SYS) converts an arbitrary LTI model SYS to state space,i.e., computes a state-space realization of SYS.

    SYS = SS(SYS,'min') computes a minimal realization of SYS.

    See also LTIMODELS, DSS, RSS, DRSS, SSDATA, LTIPROPS, TF, ZPK,FRD.

    sys=ss(a,b,c,d)

    a =

    x1 x2 x3x1 0 1 0x2 0 0 1x3 -6 -11 -6

    b =u1

    x1 0x2 0

    x3 1

    c =x1 x2 x3

    y1 1 1 1

  • 8/14/2019 Clase 1 - Control en Matlab

    5/10

    5

    d =

    u1y1 0

    Continuous-time model.

    Se usa la orden canon

    help canon

    CANON Canonical state-space realizations.

    CSYS = CANON(SYS,TYPE) computes a canonical state-space

    realization CSYS of the LTI model SYS. The string TYPEselects the type of canonical form:'modal' : Modal canonical form where the system

    eigenvalues appear on the diagonal.The state matrix A must be diagonalizable.

    'companion': Companion canonical form where the characteristicpolynomial appears in the right column.

    [CSYS,T] = CANON(SYS,TYPE) also returns the state transformationmatrix T relating the new state vector z to the old state vector

    x by z = Tx. This syntax is only meaningful when SYS is astate-space model.

    The modal form is useful for determining the relative controll-ability of the system modes. Note: the companion form is ill-conditioned and should be avoided if possible.

    See also SS2SS, CTRB, CTRBF, SS.

    Overloaded methods

    help ss/canon.mhelp lti/canon.mhelp frd/canon.m

    csys=canon(sys)

  • 8/14/2019 Clase 1 - Control en Matlab

    6/10

    6

    a =x1 x2 x3

    x1 -1 0 0x2 0 -2 0x3 0 0 -3

    b =u1

    x1 -0.86603x2 -4.5826x3 -4.7697

    c = x1 x2 x3y1 -0.57735 0.65465 -0.7338

    d =u1

    y1 0

    Continuous-time model.

    El sistema quedo diagonalizado.

    Se observa que es completamente controlable y completamente observable.

    Para comprobar controlabilidad

    help ctrb

    CTRB Compute the controllability matrix.

    CO = CTRB(A,B) returns the controllability matrix [B AB A^2B ...].

    CO = CTRB(SYS) returns the controllability matrix of thestate-space model SYS with realization (A,B,C,D). This isequivalent to CTRB(sys.a,sys.b).

  • 8/14/2019 Clase 1 - Control en Matlab

    7/10

  • 8/14/2019 Clase 1 - Control en Matlab

    8/10

    8

    See also OBSVF, SS.

    Overloaded methodshelp lti/obsv.m

    ob=obsv(a,c)

    ob =1 1 1

    -6 -10 -530 49 20

    rank(ob)

    ans =3

    El rango de ob es igual a la diemensin de la matriz a por lo tanto el sistema escompletamente observable.

    Veamos la respuesta en el tiempo:

    step(a,b,c,d)

    Time (sec.)

    Amplitude

    Step Response

    0 0.5 1 1.5 2 2.5 3 3.5 40

    0.02

    0.04

    0.06

    0.08

    0.1

    0.12

    0.14

    0.16

    0.18From: U(1)

    To:Y(1)

  • 8/14/2019 Clase 1 - Control en Matlab

    9/10

  • 8/14/2019 Clase 1 - Control en Matlab

    10/10

    10

    Simulink

    simulink

    K

    c

    K

    b

    K

    a

    Step Scope

    s

    1

    Integrator

    Step

    x' = Ax+Bu

    y = Cx+Du

    State-Space Scope