Practica 2
description
Transcript of Practica 2
UNIVERSIDAD NACIONAL DE SAN AGUSTIN AREQUIPA
FACULTAD DE INGENIERIA DE PRODUCCIÓN Y SERVICIOS
ESCUELA PROFESIONAL DE INGENIERÍA ELECTRÓNICA
CURSO : Teoría de Control Automático I
TEMA : Simulación Numérica
ALUMNOS : Chambi Mamani Pedro Omar
Dueñas Guardia Victor
2009
1. Ecuaciones diferenciales (repetir la siguiente actividad).
Determine la ecuación diferencial y=[1− y ( t ) ]
2 usando el método de Euler.
Plotear el grafico de y (t ), en función de t , y el grafico de la solución exacta ye (t) en función de t .Instante inicial: t=0, Instante final: t f=10
Solución exacta de la ecuación diferencial: ye (t )=1−e(1− t
2)
- Definimos d1.mfunction[ydot]=edo1(y)ydot=(1-y)/2
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)=edo1(y(i)); y(i+1)=y(i)+h*ydot(i); ye(i+1)=1-exp(-t(i+1)/2);endydot(n+1)=edo1(y(n+1));plot(t,y,t,ye,'r:');legend('Solución Exacta','Solución Numerica-Euler')title('Comparación entre la Solución Exacta y la Solución Numerica')xlabel('tiempo');ylabel('amplitud')- Gráfica
0 1 2 3 4 5 6 7 8 9 100
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
tiempo
ampl
itud
Comparación entre la Solución Exacta y la Solución Numerica
Solución Exacta
Solución Numerica-Euler
2. Repita las instrucciones:
F.T. H(s)=1/(s+1)
h=tf(1,[1 1]) g=ss([0 1;-5 -2],[0;3],[0 1],0)[num,den]=ss2tf([0 1;-5 -2],[0;3],[0 1],0)
g=tf(16,[1 9 16])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(224)nyquist(g)
Transfer Function16
s2+9 s+16
-100
-50
0
Mag
nitu
de (
dB)
100
102
-180
-90
0
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-8 -6 -4 -2 0-1
-0.5
0
0.5
1Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 0.5 1 1.5 2 2.50
0.5
1Step Response
Time (sec)
Am
plitu
de
-1 -0.5 0 0.5 1-1
-0.5
0
0.5
1Nyquist Diagram
Real Axis
Imag
inar
y A
xis
3. Ejercicio: Realice la simulación numérica de la ecuación diferencial descrita en el item1; Esta vez implemente el algoritmo RK4, en vez del método Euler. Haga una comparación entre las soluciones: exacta, Euler y RK4.
function[f]=rk(x,y);
f=(1-y)/2;
x(1)=0;
tf=10
y(1)=0;
ye(1)=0;
h=0.5;
n=round(tf/h);
for i=1:n;
k1=f(x(i),y(i));
k2=f(x(i)+h/2,y(i)+h/2*k1);
k3=f(x(i)+h/2,y(i)+h/2*k2);
k4=f(x(i)+h,y(i)+h*k3);
y(i+1)=y(i)+h/6*(k1+2*k2+2*k3+k4);
x(i+1)=x(i)+h;
ye(i+1)=1-exp(-t(i+1)/2);
end
ydot(n+1)=rk(y(n+1));
plot(x,y,x,ye,'r:');
legend('solución exacta','solución numerica-Euler');
title('Comparacion entre la solución exacta y la solución numerica')
xlabel('Tiempo(s)')
ylabel('Amplitud( )')
0 1 2 3 4 5 6 7 8 9 100
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
tiempo(s)
ampl
itud(
)
comparacion entre la solucion exacta y la solucion numerica
solucion exacta
solucion numerica-euler
4. Ejercicio: Repetir uno , usando la ecuación diferencial (no lineal) siguiente:
y’=2.5[y(1-y)] y(0)=0.9 Condición inicial h=0.85 paso tf=600s instante final :
function[ydot]=edo1(y)ydot=2.5*y*(1-y)
t(1)=0;tf=600;y(1)=0.9;ye(1)=0.9;h=0.85;n=round(tf/h);for i=1:nt(i+1)=t(i)+h;ydot(i)=edo1(y(i));y(i+1)=y(i)+h*ydot(i);ye(i+1)=1-exp(-t(i+1)/2);endydot(n+1)=edo1(y(n+1));plot(t,y,t,ye,'r:');legend('solución exacta','solución numerica-euler')title('comparacion entre la solución exacta y la solución numerica')xlabel('tiempo(s)');ylabel('amplitud()')
0 100 200 300 400 500 600 700
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
tiempo(s)
ampl
itud(
)
comparacion entre la solucion exacta y la solucion numerica
solucion exacta
solucion numerica-euler
G21+G2*H
1+G1 G2
G1+G21+G2*H
+ +
+
+
+ +
+
+G2
H
G1
G2
H
G1G2
R
R
C
C
R
R
C
C
5. Ejercicio: reducir el diagrama de bloques de la figura 2 y expresar la F.T. entre C y R en función de ( G1,G2 y H ).
Solución:
R +
-
+ +
G1
G2
H
C
6. Ejercicio: el propósito de estos ejercicios es familiarizarse con las funciones de
transferencia, su representación y respuesta. Ud. Podrá explorar la relación entre la
localización de polos y zeros, la respuesta temporal y la respuesta frecuencial.Por tanto,
para las siguientes funciones de transferencia grafique (i)el diagrama de polos y zeros
(ii)el diagrama de bode y (iii)la respuesta escalón unitario.
a)Transfer function: 1-----s + 1
g=tf([1],[1 1])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-40
-20
0
Magnitu
de (
dB
)
10-2
100
102
-90
-45
0
Phase (
deg)
Bode Diagram
Frequency (rad/sec)
-1 -0.5 0-1
-0.5
0
0.5
1Pole-Zero Map
Real Axis
Imagin
ary
Axis
0 2 4 60
0.5
1Step Response
Time (sec)
Am
plit
ude
-1 -0.5 0 0.5 1-1
-0.5
0
0.5
1Nyquist Diagram
Real Axis
Imagin
ary
Axis
b)Transfer function: 2----------------s^2 + 3 s + 2
g=tf([2],[1 3 2])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-100
-50
0
Mag
nitu
de (
dB)
10-2
100
102
-180
-90
0
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-2 -1.5 -1 -0.5 0-1
-0.5
0
0.5
1Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 2 4 60
0.5
1Step Response
Time (sec)
Am
plitu
de
-1 -0.5 0 0.5 1-1
-0.5
0
0.5
1Nyquist Diagram
Real Axis
Imag
inar
y A
xis
c1)Transfer function: s - 2-------2 s + 1
g=tf([1 -2],[2 1])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-10
0
10
Mag
nitu
de (
dB)
10-2
100
102
0
90
180
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-1 0 1 2-1
-0.5
0
0.5
1Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 5 10-2
-1
0
1Step Response
Time (sec)
Am
plitu
de
-2 -1 0 1-2
-1
0
1
2Nyquist Diagram
Real Axis
Imag
inar
y A
xis
c2)Transfer function: s + 2-------2 s + 1
g=tf([1 2],[2 1])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-10
0
10
Mag
nitu
de (
dB)
10-2
100
102
-40
-20
0
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-2 -1.5 -1 -0.5 0-1
-0.5
0
0.5
1Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 5 100.5
1
1.5
2Step Response
Time (sec)
Am
plitu
de
-1 0 1 2-1
-0.5
0
0.5
1Nyquist Diagram
Real Axis
Imag
inar
y A
xis
d)Transfer function: 25--------------s^2 + 2 s + 25
g=tf([25],[1 2 25])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-100
0
100
Mag
nitu
de (
dB)
10-1
100
101
102
-180
-90
0
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-1 -0.5 0-5
0
5Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 2 4 60
0.5
1
1.5
2Step Response
Time (sec)
Am
plitu
de
-2 -1 0 1 2-4
-2
0
2
4Nyquist Diagram
Real Axis
Imag
inar
y A
xis
e)Transfer function: 25 s--------------s^2 + 2 s + 25 g=tf([25 0],[1 2 25])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-50
0
50
Mag
nitu
de (
dB)
10-1
100
101
102
-90
0
90
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-1 -0.5 0-5
0
5Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 2 4 6-2
0
2
4Step Response
Time (sec)
Am
plitu
de
-5 0 5 10 15-10
-5
0
5
10Nyquist Diagram
Real Axis
Imag
inar
y A
xis
f)Transfer function: 5 s + 25--------------s^2 + 2 s + 25 g=tf([5 25],[1 2 25])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-50
0
50
Mag
nitu
de (
dB)
10-1
100
101
102
-180
0
180
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-6 -4 -2 0-5
0
5Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 2 4 60
0.5
1
1.5
2Step Response
Time (sec)
Am
plitu
de
-2 0 2 4-4
-2
0
2
4Nyquist Diagram
Real Axis
Imag
inar
y A
xis
g1)Transfer function: 25-----------------------s^3 + 3 s^2 + 27 s + 25 g=tf([25],[1 3 27 25])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-100
-50
0
Mag
nitu
de (
dB)
10-2
100
102
-360
-180
0
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-1.5 -1 -0.5 0-5
0
5Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 2 4 60
0.5
1Step Response
Time (sec)
Am
plitu
de
-1 -0.5 0 0.5 1-1
-0.5
0
0.5
1Nyquist Diagram
Real Axis
Imag
inar
y A
xis
g2)Transfer function: 125------------------------s^3 + 7 s^2 + 30 s + 125 g=tf([125],[1 7 30 125])subplot(2,2,1)bode(g)subplot(2,2,2)pzmap(g)subplot(2,2,3)step(g)subplot(2,2,4)nyquist(g)
-200
0
200
Mag
nitu
de (
dB)
100
102
-360
-180
0
Pha
se (
deg)
Bode Diagram
Frequency (rad/sec)
-6 -4 -2 0-5
0
5Pole-Zero Map
Real Axis
Imag
inar
y A
xis
0 2 4 6 80
0.5
1
1.5Step Response
Time (sec)
Am
plitu
de
-4 -2 0 2-4
-2
0
2
4Nyquist Diagram
Real Axis
Imag
inar
y A
xis