Diferencia entre revisiones de «Usuario:Grupo 4»
De MateWiki
(→Resolución mediante Euler modificado.) |
(→Resolución mediante Runge-Kutta de orden 4.) |
||
| Línea 56: | Línea 56: | ||
===Resolución mediante Runge-Kutta de orden 4.=== | ===Resolución mediante Runge-Kutta de orden 4.=== | ||
| + | |||
| + | {{matlab|codigo= | ||
| + | clc | ||
| + | clear all | ||
| + | %Datos iniciales | ||
| + | %Numero de ecuaciones | ||
| + | ne=3; | ||
| + | %Tiempo inicial | ||
| + | t0=0; | ||
| + | %Tiempo final | ||
| + | tn=20; | ||
| + | %Tamaño del salto | ||
| + | h=0.05; | ||
| + | %Numero de elementos | ||
| + | N=round((tn-t0)/h); | ||
| + | %Determinacion del vector t | ||
| + | t=linspace(t0,tn,N+1); | ||
| + | %Vector k, valor inicial de f(3) | ||
| + | k0=0.1; | ||
| + | kf=1; | ||
| + | k=k0:0.01:kf; | ||
| + | G=length(k); | ||
| + | %Sistema de ecuaciones | ||
| + | w=inline('[f(2);f(3);-1/2*f(1)*f(3)]','t','f'); | ||
| + | f=zeros(ne,N+1); | ||
| + | %Resolucion | ||
| + | for j=1:G | ||
| + | f0=[0 0 k(j)]; | ||
| + | f(:,1)=f0; | ||
| + | for i=1:N | ||
| + | K1=w(t(i),f(:,i)); | ||
| + | t(i)=t(i)+h/2; | ||
| + | z(:,i)=f(:,i)+K1*h/2; | ||
| + | K2=w(t(i),z(:,i)); | ||
| + | v(:,i)=f(:,i)+K2*h/2; | ||
| + | K3=w(t(i),v(:,i)); | ||
| + | c(:,i)=f(:,i)+K3*h; | ||
| + | K4=w(t(i)-h/2,c(:,i)); | ||
| + | f(:,i+1)=f(:,i)+(h/6)*(K1+2*K2+2*K3+K4); | ||
| + | end | ||
| + | Y(j)=f(2,end); | ||
| + | end | ||
| + | plot(k,Y) | ||
| + | for q=1:G | ||
| + | a(q)=abs(Y(q)-1); | ||
| + | end | ||
| + | l=min(a); | ||
| + | for q=1:G | ||
| + | b(q)=abs(Y(q)-1); | ||
| + | if min(b)==l | ||
| + | k(q) | ||
| + | break | ||
| + | end | ||
| + | }} | ||
===Resolución mediante Euler.=== | ===Resolución mediante Euler.=== | ||
Revisión del 20:05 27 abr 2016
| Trabajo realizado por estudiantes | |
|---|---|
| Título | Fluido por encima de una placa plana. Grupo 4 |
| Asignatura | Ecuaciones Diferenciales |
| Curso | Curso 2015-16 |
| Autores | Ruben Martos López, Guillermo Megino León, Silviu Popa Alejandro Sistac Ara, |
| Este artículo ha sido escrito por estudiantes como parte de su evaluación en la asignatura | |
Contenido
1 Introducción.
2 Resolución numérica del problema.
2.1 Resolución mediante Euler modificado.
clc
clear all
%Datos iniciales
%Numero de ecuaciones
ne=3;
%Tiempo inicial
t0=0;
%Tiempo final
tn=20;
%Tamaño del salto
h=0.05;
%Numero de elementos
N=round((tn-t0)/h);
%Determinacion del vector t
t=linspace(t0,tn,N+1);
%Vector k, valor inicial de f(3)
k0=0.1;
kf=1;
k=k0:0.01:kf;
G=length(k);
%Sistema de ecuaciones
w=inline('[f(2);f(3);-1/2*f(1)*f(3)]','t','f');
f=zeros(ne,N+1);
%Resolucion
for j=1:G
f0=[0 0 k(j)];
f(:,1)=f0;
for i=1:N
K1=w(t(i),f(:,i));
t(i)=t(i)+h/2;
z(:,i)=f(:,i)+K1*h/2;
f(:,i+1)=f(:,i)+h*w(t(i),z(:,i));
end
Y(j)=f(2,end);
end
plot(k,Y)
for q=1:G
a(q)=abs(Y(q)-1);
end
l=min(a);
for q=1:G
b(q)=abs(Y(q)-1);
if min(b)==l
k(q)
break
end
2.2 Resolución mediante Runge-Kutta de orden 4.
clc
clear all
%Datos iniciales
%Numero de ecuaciones
ne=3;
%Tiempo inicial
t0=0;
%Tiempo final
tn=20;
%Tamaño del salto
h=0.05;
%Numero de elementos
N=round((tn-t0)/h);
%Determinacion del vector t
t=linspace(t0,tn,N+1);
%Vector k, valor inicial de f(3)
k0=0.1;
kf=1;
k=k0:0.01:kf;
G=length(k);
%Sistema de ecuaciones
w=inline('[f(2);f(3);-1/2*f(1)*f(3)]','t','f');
f=zeros(ne,N+1);
%Resolucion
for j=1:G
f0=[0 0 k(j)];
f(:,1)=f0;
for i=1:N
K1=w(t(i),f(:,i));
t(i)=t(i)+h/2;
z(:,i)=f(:,i)+K1*h/2;
K2=w(t(i),z(:,i));
v(:,i)=f(:,i)+K2*h/2;
K3=w(t(i),v(:,i));
c(:,i)=f(:,i)+K3*h;
K4=w(t(i)-h/2,c(:,i));
f(:,i+1)=f(:,i)+(h/6)*(K1+2*K2+2*K3+K4);
end
Y(j)=f(2,end);
end
plot(k,Y)
for q=1:G
a(q)=abs(Y(q)-1);
end
l=min(a);
for q=1:G
b(q)=abs(Y(q)-1);
if min(b)==l
k(q)
break
end