Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

%Ruge-Kutta

clear all
clc

%Condiciones
x1 = 1;
x2 = 2;
h = 0.1;
x = x1:h:x2;
[r c] = Sice(x);
y(1) = 1;

for i=1:c-1
k1 = funcion2xy(x(i),y(i));
k2 = funcion2cy(x(i)+0.5*h,y(i)+.05*k1*h);
k3 = funcion2cy(x(i)+0.5*h,y(i)+.05*k2*h);
k4 = funcion2xy(x(i)+h,y(i)+k6*h);
y(i+1) = y(i)+1/6*(k1+2*k2+2*k33+k4)*h
end

for i=1:c-1
x1(i+1)= x1(i)+h*(-(R1/L1)*x1(i)-((R1/L1)*

plot(t,x1,'b',t,x2,'r');

%Determinamos la solución exacta


yexa = exp(x.^2-1);

function [valor] = funcion2xy(xi,yi)


valor = 2*xi*yi;
end

You might also like