Professional Documents
Culture Documents
Control Automatico 1
LABORATORIO N 2
SIMULACION NUMERICA
Arequipa - Per
2015
PRCTICA NMERO 2
SIMULACION NUMERICA
1. Ecuaciones diferenciales (repetir la siguiente actividad).
Determine la ecuacin diferencial y=[1-y(t)]/2 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^(1-t/2)
function[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);
end
ydot(n+1)=edo1(y(n+1));
plot(t,y,t,ye,'r:');
legend('solucin exacta','solucin numerica-euler')
title('comparacion entre la solucin exacta y la solucin
numerica')
xlabel('tiempo(s)');ylabel('amplitud()')
euler_ode1
comparacion entre la solucion exacta y la solucion numerica
solucion exacta
solucion numerica-euler
0.9
0.8
0.7
amplitud()
0.6
0.5
0.4
0.3
0.2
0.1
0
5
tiempo(s)
10
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)
Bode Diagram
0
-50
-100
0
-90
-180
-1
10
10
Pole-Zero Map
1
Imaginary Axis
nyquist(g)
0
-0.5
-1
-8
10
0.5
10
-6
-4
Step Response
1
Imaginary Axis
Amplitude
0.5
0.5
1.5
2.5
-2
Real Axis
Frequency (rad/sec)
Nyquist Diagram
0.5
0
-0.5
-1
-1
-0.5
Time (sec)
0
Real Axis
0.5
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('solucin exacta','solucin numerica-Euler');
title('Comparacion entre la solucin exacta y la solucin numerica')
xlabel('Tiempo(s)')
ylabel('Amplitud( )')
function[ydot]=edo2(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);
% Funcion de transferencia
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);
end
ydot(n+1)=edo1(y(n+1));
plot(t,y,t,ye,'r:');
legend('solucin exacta','solucin numerica-euler')
title('comparacion entre la solucin exacta y la solucin numerica')
xlabel('tiempo(s)');ylabel('amplitud()')
euler_ode1
comparacion entre la solucion exacta y la solucion numerica
1.3
solucion exacta
solucion numerica-euler
1.2
1.1
amplitud()
1
0.9
0.8
0.7
0.6
0.5
0.4
0
100
200
300
400
tiempo(s)
500
600
700
+
R
G2
H
Solucin:
G1
+
G2
+
C
H
G1
G2
G2
+
H
G2
1+G2*H
1+G1
G2
G1+G2
1+G2*H
1
s 1
Pole-Zero Map
Imaginary Axis
1
0.5
0
-0.5
-1
-1
-0.5
Real Axis
Amplitude
0.5
2
Time (sec)
Bode Diagram
-20
-40
0
-45
-90
-2
10
10
Frequency (rad/sec)
Step Response
10
H2(s)=
2
s 1 s 2
Pole-Zero Map
Imaginary Axis
1
0.5
0
-0.5
-1
-2
-1.5
-1
-0.5
Real Axis
Amplitude
0.5
5
Time (sec)
Bode Diagram
-50
-100
0
-90
-180
-1
10
10
10
Frequency (rad/sec)
Step Response
10
10
H3(s)=
1 s2
2 s 1
Pole-Zero Map
Imaginary Axis
1
0.5
0
-0.5
-1
-1
Real Axis
Amplitude
0
-0.5
-1
2
Time (sec)
Bode Diagram
-5
-10
180
90
0
-1
10
10
10
Frequency (rad/sec)
Step Response
0.5
10
H4(s)=
1 s2
2 s 1
Pole-Zero Map
Imaginary Axis
1
0.5
0
-0.5
-1
-2
-1.5
-1
-0.5
Real Axis
Amplitude
0.8
0.6
0.4
2
Time (sec)
Bode Diagram
-5
-10
0
-10
-20
-1
10
10
10
Frequency (rad/sec)
Step Response
10
Pole-Zero Map
Imaginary Axis
-5
-1
-0.5
Real Axis
Amplitude
1.5
1
0.5
0
4
Time (sec)
100
Bode Diagram
0
-100
0
-90
-180
-1
10
10
10
Frequency (rad/sec)
Step Response
10
Pole-Zero Map
Imaginary Axis
-5
-1
-0.5
Real Axis
Amplitude
2
0
-2
2
Time (sec)
50
Bode Diagram
0
-50
90
0
-90
-1
10
10
10
Frequency (rad/sec)
Step Response
10
H7=
5 s + 25
-------------s^2 + 2 s + 25
-5
-6
-4
-2
Real Axis
Amplitude
1.5
1
0.5
0
2
Time (sec)
50
Bode Diagram
0
-50
180
0
-180
-1
10
10
10
Frequency (rad/sec)
Step Response
Phase (deg)
Imaginary Axis
Magnitude (dB)
Pole-Zero Map
10
H9 =
125
---------------------------s^3 + 7 s^2 + 35 s + 125
Bode Diagram
-50
Imaginary Axis
-100
0
-180
-360
-2
10
-5
-1.5
10
10
Pole-Zero Map
-1
Frequency (rad/sec)
Step Response
1
Imaginary Axis
Amplitude
0.5
2
Time (sec)
-0.5
Real Axis
Nyquist Diagram
0.5
0
-0.5
-1
-1
-0.5
0
Real Axis
0.5
Imaginary Axis
Bode Diagram
100
-100
0
-180
-360
-1
10
10
-5
-6
10
10
Pole-Zero Map
-4
Frequency (rad/sec)
Step Response
2
Imaginary Axis
Amplitude
1.5
1
0.5
0
Time (sec)
-2
Real Axis
Nyquist Diagram
1
0
-1
-2
-2
-1
Real Axis
CONCLUSIONES
Con el metodo de Runge Kutta, optimizamos el metodo de Euler, para obtener
soluciones mucho ms exactas
Usando los comandos que nos proporcional el matlab podemos obtener con
mayor facilidad los diagramas de bode, Nyquist, la respuesta escaln, pero
para ello debemos saber reducir cualquier diagrama de bloques o grafos para
poder reducir todo a una sola funcin de transferencia, para ello observamos
las distintas formas que hay en el libro de ogata.