Está en la página 1de 2

% ‘RUNGE KUTTA 4 ORDEN 2 SITEMAS DE ECUACIONES’

Format short

to=input(‘inserte el valor de to inicial: ‘);

tf=input(‘inserte el valor de tf inicial: ’);

h=input(‘inserte el valor de tamaño de paso: ’);

syms x y xi yi t z

f=inpu(‘ingrese la función f ’)

g=input(‘ingrese la función g ‘)

d=(tf-t0)/h;

disp.(‘ i t x y ‘)

disp.(‘-----------------‘)

r=zeros(d,4);

p=zeros(d,3);

t=to;

x=input (‘inserte dato inicial de x: ’);

y=input (‘inserte el dato inicial de y: ’);

for i=1:1:d+1

x0=x;

to=t;

yo=y;

r(i,1)=i;

r(i,2)=t;

r(i,3)=x;

r=(i,4)=y;

p(i,1)=t;

p(i,2)=x;

p(i,3)=y;

k1=eval(f);

l1=eval(g);

k2=[t0+(h/2),x0+(h/2)*k1,y0+(h/2)*l1];

t=k2(1);
x=k2(2);

y=k2(3);

k2=eval(f);

l2=[t0+(h/2),x0+(h/2)*k1,y0+(h/2)*l1];

l2=eval(g);

k3=[t0+(h/2),x0+(h/2)*k2,y0+(h/2)*l2];

t=k3(1);

x=k3(2);

y=k3(3);

k3=eval(f);

l3=[t0+(h/2),x0+(h/2)*k2,y0+(h/2)*l2];

l3=eval(g);

k4=[t0+(h),x0+(h)*k3,y0+(h)*l3];

t=k4(1);

x=k4(2);

y=k4(3);

k4=eval(f);

l4=[t0+(h),x0+(h)*k3,y0+(h)*l3];

l4=eval(g);

x=x0+(h/6)*(k1+2*k2+2*k3+k4);

y=y0+(h/6)*(l1+2*l2+2*l3+l4);

t=t0+h;

end

%impresion de datos

surf(p)

zlabel(‘y’);

xlabel(‘t’);

ylabel(‘x’);

title(‘Runge-Kutta 4 orden dos funciones 3 variables’);

También podría gustarte