
Simulación en MATLAB
Publicado por Patricia (2 intervenciones) el 11/05/2014 15:21:20
Hola! Mi nombre es Patricia y realmente tengo un problema que no puedo resolver..... (consulté en distintas Universidades):
Necesito simular numéricamente empleando el método de RUNGE KUTTA DE ORDEN 4 un sistema de ecuaciones diferenciales de TRES variables del tipo PRESA - DEPREDADOR y también necesito simular la representación gráfica del espacio FASE del sistema, es decir representar las variables X, Y , Z en 3D.
A continuación envío lo que hice (que no funciona) utilizando un ejemplo específico de un sistema de ecuaciones diferenciales de tres variables:
ARCHIVO 1: Método de RUNGE KUTTA DE ORDEN 4
ARCHIVO 2: CON PASO CONSTANTE “ h” , sé que existe una programación con paso adaptativo h, pero es suficiente con que lo haga con un paso constante.
MUCHAS GRACIAS Y ESPERO QUE ALGUIEN PUEDA AYUDARME.......!! Patricia (11/05/14)
Necesito simular numéricamente empleando el método de RUNGE KUTTA DE ORDEN 4 un sistema de ecuaciones diferenciales de TRES variables del tipo PRESA - DEPREDADOR y también necesito simular la representación gráfica del espacio FASE del sistema, es decir representar las variables X, Y , Z en 3D.
A continuación envío lo que hice (que no funciona) utilizando un ejemplo específico de un sistema de ecuaciones diferenciales de tres variables:
ARCHIVO 1: Método de RUNGE KUTTA DE ORDEN 4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function sskk(xx,yy,zz,x,y,z,t,h)
u1=h*eval('xx(t,x,y,z)');
v1=h*eval('yy(t,x,y,z)');
w1=h*eval('zz(t,x,y,z)');
u2=h*eval('xx(t+h/2,x+u1/2,y+v1/2,z+w1/2)');
v2=h*eval('yy(t+h/2,x+u1/2,y+v1/2,z+w1/2)');
w2=h*eval('zz(t+h/2,x+u1/2,y+v1/2,z+w1/2)');
u3=h*eval('xx(t+h/2,x+u2/2,y+v2/2,z+w2/2)');
v3=h*eval('yy(t+h/2,x+u2/2,y+v2/2,z+w2/2)');
w3=h*eval('zz(t+h/2,x+u2/2,y+v2/2,z+w2/2)');
u4=h*eval('xx(t+h,x+u3,y+v3,z+w3)');
v4=h*eval('yy(t+h,x+u3,y+v3,z+w3)');
w4=h*eval('yy(t+h,x+u3,y+v3,z+w3)');
xx1=x+(1/6)*(u1+2*u2+2*u3+u4);
yy1=y+(1/6)*(v1+2*v2+2*v3+v4);
zz1=z+(1/6)*(w1+2*w2+2*w3+w4);
q=[xx1,yy1,zz1];
ARCHIVO 2: CON PASO CONSTANTE “ h” , sé que existe una programación con paso adaptativo h, pero es suficiente con que lo haga con un paso constante.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
clear
clc
disp(' SISTEMA DE 3 EDOs ')
disp(' ')
r=inline('250-0.25*x-50*x*z','t','x','y','z'); %funcion uno
s=inline('137.5-0.25*y+10*y*z','t','x','y','z'); %funcion dos
p=inline('0.01*x*z-0.006*y*z','t','x','y','z'); %funcion tres
t0=input('Ingrese el valor del tiempo inicial,t0:');
tf=input('Ingrese el valor del tiempo final, tf:'); %el tiempo
h=input('Ingrese el valor del paso h:');
t=t0;
x0=input('Ingrese,x(0):');
y0=input('Ingrese,y(0):');
z0=input('Ingrese,z(0):');
a = sskk(r,s,p,x0,y0,z0,t,h); En esta línea me marca error: TOO MANY OUTPUT ARGUMENTS
tab=[t,a];
g=a;
while(t<tf)
x0=a(1); %valor de x en t=0
y0=a(2); %valor de y en t=0
z0=a(3); %valor de z en t=0
t=t+h;
tab=[tab;t,x0,y0,z0]; %concatenacion para formar la matriz de salida
a=sskk(r,s,p,x0,y0,z0,t,h);
g=[g;a]; %concatenacion para formar un vector a graficar
end
u=0:h:tf; %dominio para graficacion%
hold on
plot(u',g) %grafica para el modelo RK4
disp('Resultados del calculo con el metodo de Runge - Kutta de 4° orden:')
disp('columna 1: t columna 2: x(t) columna 3: y(t) columna 4: z(t)')
tab
title(['SOLUCION DEL SISTEMA PRESA-DEPREDADOR CON h='])
xlabel('TIEMPO (t)')
ylabel('CANTIDAD DE INDVIDUOS')
zlabel('CANTIDAD DE INDIVIDUOS')
MUCHAS GRACIAS Y ESPERO QUE ALGUIEN PUEDA AYUDARME.......!! Patricia (11/05/14)
Valora esta pregunta


0