Vous êtes sur la page 1sur 10

1

CONTROL 2

Uso del Matlab

Considere el siguiente sistema:

 x&1   0 1 0   x1  0
 x&  =  0 0 1   x2  + 0  u
  2    
 x&3  − 6 − 11 − 6  x3  1

 x1 
y = [1 1 1] x2 
 
 x3 
Lo primero es digitar las matrices en Matlab

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

a=
0 1 0
0 0 1
-6 -11 -6

b=[0;0;1]

b=
0
0
1

c=[1,1,1]

c=
1 1 1
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 square
matrix X.

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


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

[V,D] = EIG(X,'nobalance') performs the computation with balancing


disabled, which sometimes gives more accurate results for certain
problems with unusual scaling.

E = EIG(A,B) is a vector containing the generalized eigenvalues


of square matrices A and B.

[V,D] = EIG(A,B) produces a diagonal matrix D of generalized


eigenvalues and a full matrix V whose columns are the
corresponding eigenvectors so that A*V = B*V*D.

See also CONDEIG, EIGS.

Overloaded methods
help sym/eig.m
help lti/eig.m

eig(a)

ans =
-1.0000
-2.0000
-3.0000
3

[m,ed]=eig(a)

m=
-0.5774 0.2182 -0.1048
0.5774 -0.4364 0.3145
-0.5774 0.8729 -0.9435
ed =
-1.0000 0 0
0 -2.0000 0
0 0 -3.0000

Se observa la matriz modal m y en la matriz ed los polos en la diagonal


principal.

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) model
SYS with matrices A,B,C,D. The output SYS is a SS object. You
can 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 sample


time 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 an
existing 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 for
A,B,C,D above. The first two dimensions of A,B,C,D determine the
number of states, inputs, and outputs, while the remaining
4

dimensions specify the array sizes. For example, if A,B,C,D are


4D 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 of
outputs, inputs, and states.

SYS = SS(ZEROS([NY NU S1...Sk])) pre-allocates space for an SS array


with 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 x3
x1 0 1 0
x2 0 0 1
x3 -6 -11 -6

b=
u1
x1 0
x2 0
x3 1

c=
x1 x2 x3
y1 1 1 1
5

d=
u1
y1 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 TYPE
selects 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 characteristic
polynomial appears in the right column.

[CSYS,T] = CANON(SYS,TYPE) also returns the state transformation


matrix T relating the new state vector z to the old state vector
x by z = Tx. This syntax is only meaningful when SYS is a
state-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.m
help lti/canon.m
help frd/canon.m

csys=canon(sys)
6

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

b=
u1
x1 -0.86603
x2 -4.5826
x3 -4.7697

c=
x1 x2 x3
y1 -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 the


state-space model SYS with realization (A,B,C,D). This is
equivalent to CTRB(sys.a,sys.b).
7

For ND arrays of state-space models SYS, CO is an array with N+2


dimensions where CO(:,:,j1,...,jN) contains the controllability
matrix of the state-space model SYS(:,:,j1,...,jN).

See also CTRBF, SS.

Overloaded methods
help lti/ctrb.m

co=ctrb(a,b)

co =
0 0 1
0 1 -6
1 -6 25

rank(co)

ans =
3

El rango de la matriz de controlabilidad es 3 y es igual a la dimensión de la


matriz a, por lo tanto el sistema es completamente controlable.

Para verificar la observabilidad se usa el comando obsv

help obsv

OBSV Compute the observability matrix.

OB = OBSV(A,C) returns the observability matrix [C; CA; CA^2 ...]

CO = OBSV(SYS) returns the observability matrix of the


state-space model SYS with realization (A,B,C,D). This is
equivalent to OBSV(sys.a,sys.c).

For ND arrays of state-space models SYS, OB is an array with N+2


dimensions where OB(:,:,j1,...,jN) contains the observability
matrix of the state-space model SYS(:,:,j1,...,jN).
8

See also OBSVF, SS.

Overloaded methods
help lti/obsv.m

ob=obsv(a,c)

ob =
1 1 1
-6 -10 -5
30 49 20

rank(ob)

ans =
3

El rango de ob es igual a la diemensión de la matriz a por lo tanto el sistema es


completamente observable.

Veamos la respuesta en el tiempo:

step(a,b,c,d)

Step Response
From: U(1)
0.18

0.16

0.14

0.12
Amplitude

0.1
To: Y(1)

0.08

0.06

0.04

0.02

0
0 0.5 1 1.5 2 2.5 3 3.5 4

Time (sec.)
9

[num,den]=ss2tf(a,b,c,d)

num =
0 1.0000 1.0000 1.0000
den =
1.0000 6.0000 11.0000 6.0000

step(num,den)

Step Response
From: U(1)
0.18

0.16

0.14

0.12
Amplitude

0.1
To: Y(1)

0.08

0.06

0.04

0.02

0
0 0.5 1 1.5 2 2.5 3 3.5 4

Time (sec.)

sistema=tf(num,den)

Transfer function:
s^2 + s + 1
----------------------
s^3 + 6 s^2 + 11 s + 6

roots(den)

ans =
-3.0000
-2.0000
-1.0000
10

Simulink
simulink

1
K K
s
Step b Integrator c Scope

x' = Ax+Bu
y = Cx+Du
Step State-Space Scope