You are on page 1of 4

UNIVERSIDAD POLITECNICA SALESIANA

Integrantes: Andrea Figueroa - Rafael Larrea

Mecatronica nivel 6

19/07/2017

METODO EULER PARA RESOLUCION ECUACIONES DIFERENCIALES

PASO H

H=1

H=0.5

H=0.25
Código Matlab usado para la resolución de este método Euler
clc
clear all

syms t y z
y0=0;
z0=0;

F(1)=input('Ingrese primera ecuacion f1= ');


F(2)=input('Ingrese segunda ecuacion f2= ');
t0=input('ingrese valor inicial del intervalo de tiempo t0= ');
tf=input('ingrese valor final del intervalo de tiempo tf= ');
h=input('ingrese paso h= ');
y0=input('ingrese valor inicial y(0)= ');
z0=input('ingrese valor inicial y´(0)= ');

y=y0;
z=z0;
t=t0;

c=0;
fprintf('\t iteraciones \t|\t t \t|\t y \t|\t z \t\n ')
fprintf('\t %i \t|\t %6.5f \t|\t %6.5f \t|\t% 6.5f \t\n ',c,t,y,z);
vector(c+1)=y;

while t<=tf-h

c=c+1;
y = y + (eval(F(1)))*h;
z = z + (eval(F(2)))*h;
t=t+h;
fprintf('\t %i \t|\t %6.5f \t|\t %6.5f \t|\t %6.5f \t\n
',c,t,y,z)
vector(c+1)=y;

end
t=t0:h:tf;
hold on
plot(t,vector,'LineWidth',4);

GRAFICA DE LAS SOLUCIONES CON LOS DIFERENTES PASOS H (1, 0.5, 0.25)

- CON PASO 1

- CON PASO 0.5

- CON PASO 0.25

Comparación de resultados
Grafica solución analítica

You might also like