Está en la página 1de 13

Luna Urbina, Gabriel

LAB 2

LABORATORIO

DE CONTROL AUTOMATICO I

TEMA: SIMULACIN NUMRICA


1. ECUACIONES DIFERENCIALES (REPETIR LA SIGUIENTE
ACTIVIDAD) DETERMINE LA SOLUCIN DE LA ECUACIN DIFERENCIAL

Usando el mtodo de Euler. Plotear el grafico de y(t) en funcin de t, y el grafico de la solucin exacta ye(t) en funcin de t. Instante inicial: t = 0 Instante final: tf = 10 Solucin exacta de la ecuacin diferencial: ye(t) = 1 e(1t=2)
1 CREAMOS UN FILE edo1.m DONDE SE DEFINE LA ECUACIN:

function[ydot]=edol1(y) ydot=(1-y)/2;

2 CREAMOS OTRO FILE IMPLEMENTANDO EL ALGORITMO SIGUIENTE Y LO GUARDAMOS CON EL NOMBRE euler_ode1.m
t(1)=0; tf=10; y(1)=0; ye(1)=0; h=0.5; n=round(tf/h); for i=1:n t(i+1)=t(i)+h; ydot(i)=edol1(y(i)); y(i+1)=y(i)+h*ydot(i); ye(i+1)=1-exp(-t(i+1)/2); end ydot(n+1)=edol1(y(n+1)); plot(t,y,t,ye,'r:'); legend('Solucin numerica-euler','Solucin exacta'); title('Comparacion entre la solucin exacta y la solucin numerica'); xlabel('Tiempo(s)'); ylabel('Amplitud()');

Ejecutar la simulacin, en el workspace donde se ha de digitar euler_ode1 y ese obtendr la siguiente grafica:

Luna Urbina, Gabriel

LAB 2

En el rea de trabajo digitamos: >> euler_ode1

2. REPITA LAS INSTRUCCIONES LE AYUDAR A ENTENDER COMO INTRODUCIR


FUNCIONES DE TRANSFERENCIA EN MATLAB. PRINCIPALES GRFICAS PARA FACILITAR EL ANLISIS DE SISTEMAS LTI. A continuacin se define una funcin de transferencia que tiene la forma:

g (s) =

16 s + 9 s + 16
2

Luego se hallamos ciertas caractersticas de esta; >> g=tf([16],[1 9 16]); >> subplot(221); >> bode(g); >> subplot(222); >> pzmap(g); >> subplot(223); >> step(g); >> subplot(224); %respuesta al escaln unitario %grafico de polos y ceros %diagrama de bode %definimos nuestro sistema

Luna Urbina, Gabriel

LAB 2 %diagrama de nyquis

>> nyquist(g);

3.
REALICE LA SIMULACIN NUMRICA DE LA ECUACIN DIFERENCIAL DESCRITA EN EL ITEM1; ESTA VEZ IMPLEMENTE EL ALGORITMO RK4, EN VES DEL MTODO EULER. HAGA UNA COMPARACIN ENTRE LAS SOLUCIONES: EXACTA, EULER Y RK4. 1 Creamos El File Rk4.M Con El Siguiente Contenido: function [ydot]=edo1(y); ydot=(1-y)/2; 2 En Otro File Digitamos El Algoritmo. x(1)=0; tf=10 y(1)=0; ye(1)=0; h=0.5; n=round(tf/h);

Luna Urbina, Gabriel

LAB 2

for i=1:n; k1=2*(1-y(i))/2; k2=(1-y(i)-h/2*k1)/2; k3=(1-y(i)-h/2*k2)/2; k4=(1-y(i)-h*k3)/2; y(i+1)=y(i)+h/6*(k1+2*k2+2*k3+k4); x(i+1)=x(i)+h; ye(i+1)=1-exp(-x(i+1)/2); end ydot(n+1)=rk4(y(n+1)); plot(x,y,x,ye,'r:'); legend('solucin numrica-RK4','solucin exacta'); title('Comparacin entre la solucin exacta y la solucin numrica') xlabel('Tiempo(s)') ylabel('Amplitud( )') SE OBTIENE EL SIGUIENTE GRAFICO:

4.

REPETIR

1., USANDO LA ECUACIN DIFERENCIAL (NO LINEAL) SIGUIENTE:

Luna Urbina, Gabriel

LAB 2

y = 2.5[y(1-y)] , y(0)=0.9 Condicin inicial h=0.85, paso tf=600s instante final.


EN ESTE CASO LA SOLUCIN EXACTA ESTAR DADA POR:

ye (t ) =

1 1e
2.5t +0.9

SE CREA UN file.m DEFINIENDO LA ECUACIN DIFERENCIAL.

function[ydot]=edo1(y) ydot=2.5*y*(1-y) EN OTRO FILE DEFINIMOS EL ALGORITMO PARA HALLAR LA SOLUCIN DE LA ECUACIN DIFERENCIAL. t(1)=0; tf=600; y(1)=0.9; ye(1)=0.9; h=0.85; n=round(tf/h); for i=1:n t(i+1)=t(i)+h; ydot(i)=edo1(y(i)); y(i+1)=y(i)+h*ydot(i); ye(i+1)=(1-exp(-2.5*t(i+1)+0.9))^(-1); end ydot(n+1)=edo1(y(n+1)); plot(t,y,t,ye,'r:'); legend('Solucin numerica-euler','solucin exacta')

Luna Urbina, Gabriel

LAB 2

title('Comparacion entre la solucin exacta y la solucin numerica') xlabel('Tiempo(s)');ylabel('Amplitud()')


EN LA VENTANA COMMAND WINDOW DE MATLAB DIGITAMOS EL NOMBRE DEL SEGUNDO FILE:

Ejecutar la simulacin, en el workspace donde se ha de digitar


>>euler2

y ese obtendr la siguiente grafica:

5.

REDUCIR EL DIAGRAMA DE BLOQUES DE LA FIGURA 2 Y EXPRESAR LA F.T. ENTRE C Y R EN FUNCIN DE ( G1,G2 Y H ).

G1

+ R H

G2 +

+ C

Luna Urbina, Gabriel

LAB 2

Solucin G1 R G2 H C

+ R H G2

G1 G2

G2 1 + G 2 .H

1+

G1 G2

G 2 + G1 1 + G2 * H

6.

EL PROPSITO DE ESTOS EJERCICIOS ES FAMILIARIZARSE CON LAS

FUNCIONES DE TRANSFERENCIA, SU REPRESENTACIN Y RESPUESTA. UD. PODR EXPLORAR LA RELACIN ENTRE LA LOCALIZACIN DE POLOS Y CEROS, LA RESPUESTA TEMPORAL Y LA RESPUESTA FRECUENCIAL. POR TANTO, PARA LAS SIGUIENTES FUNCIONES DE TRANSFERENCIA GRAFIQUE (I)EL DIAGRAMA DE POLOS Y CEROS (II) EL DIAGRAMA DE BODE Y (III) LA RESPUESTA ESCALN UNITARIO. A) Sistema de primer orden: H 1 ( s) = 1 s +1

Luna Urbina, Gabriel

LAB 2

>>h=tf([1],[1 1]); >>subplot(2,2,1); >>pzmap(g); >>subplot(2,2,2); >>bode(g); >>subplot(2,2,3); >>step(g);

Se obtuvo la siguiente grafica.

b) Sistema de segundo orden:


2

H 2 (s) =

( s +1)( s + 2)

Luna Urbina, Gabriel

LAB 2

>>h=tf(2,[conv([1 1],[1 2])]); >>subplot(2,2,1); >>pzmap(g); >>subplot(2,2,2); >>bode(g); >>subplot(2,2,3); >>step(g);


SE OBTIENE LA SIGUIENTE GRAFICA:

c) SISTEMA DE PRIMER ORDEN (ADICIONAMOS UN CERO, PRIMERO EN EL RHP, LUEGO EN EL LHP): 1 ( s 2) 2 ( s + 1)

1.

H 3 ( s) =

>>h=tf(0.5*[1 -2],[1 1]) ; >>subplot(2,2,1) ;

Luna Urbina, Gabriel

LAB 2

>>pzmap(g) ; >>subplot(2,2,2) ; >>bode(g) ; >>subplot(2,2,3) ; >>step(g) ;

2.

H 4 ( s) =

1 ( s + 2) 2 ( s + 1)

>>h=tf(0.5*[1 2],[1 1]) ; >>subplot(2,2,1) ; >>pzmap(g) ; >>subplot(2,2,2) ; >>bode(g) ; >>subplot(2,2,3) ; >>step(g) ;

Luna Urbina, Gabriel

LAB 2

d) El siguiente sistema es un sistema de segundo orden, con Wn=5 y un =0.2

H 5 ( s) =
>>h=tf(25,[1 2 25]) ; >>subplot(2,2,1) ; >>pzmap(g) ; >>subplot(2,2,2) ; >>bode(g) ; >>subplot(2,2,3) ; >>step(g) ;

25 s + 2 s + 25
2

Luna Urbina, Gabriel

LAB 2

e) Ahora adicionamos un cero sobre el origen:

H 6 ( s) =

25s s + 2 s + 25
2

>>h=tf([25 0],[1 2 25]) ; >>subplot(2,2,1) ; >>pzmap(g) ; >>subplot(2,2,2) ; >>bode(g) ; >>subplot(2,2,3) ; >>step(g) ;

Luna Urbina, Gabriel

LAB 2

f)

Ahora adicionamos un cero a 5 rad/seg:

H 7 ( s) =
>>h=tf(5*[1 5],[1 2 25]) ; >>subplot(2,2,1) ; >>pzmap(g) ; >>subplot(2,2,2) ; >>bode(g) ; >>subplot(2,2,3) ; >>step(g) ;

5s + 25 s + 2 s + 25
2

También podría gustarte