% Método de RK4Orden ---------------------------------------
% x-Vector de tiempo
% y1,y2-Vectores de carga y corriente
% li-Limite inferior en el tiempo
% ls-Limite superior superior en el tiempo
% h-Paso
clear
% Parámetros del circuito -----------------------------------------
R=2;
L=3;
C=1;
Et=8;
% Ecuaciones Diferenciales Ordinarias dy/dx=f(x,y) a resolver --------------
f1=@(x,y1,y2) ;
f2=@(x,y1,y2) ;
% Condiciones iniciales -----------------------------------------------
x(1)=;
y1(1)=;
y2(1)=;
li=0
ls=5
h=0.5
% Método de RK4Orden ---------------------------------------------------
while x(end)<=xn
k11= f1(x(end),y1(end));
k21= f1(x(end)+.5*h,y1(end)+.5*h*k11);
k31= f1(x(end)+.5*h,y1(end)+.5*k21*h);
k41= f1(x(end)+h,y1(end)+k13*h);
x(end+1)=x(end)+h;
y1(end+1)=y1(end)+1/6*(k11+2*k21+2*k31+k41)*h;
end
while x(end)<=xn
k12= f2(x(end),y2(end));
k22= f2(x(end)+.5*h,y2(end)+.5*h*k12);
k32= f2(x(end)+.5*h,y2(end)+.5*k22*h);
k42= f2(x(end)+h,y2(end)+k32*h);
x(end+1)=x(end)+h;
y2(end+1)=y2(end)+1/6*(k12+2*k22+2*k32+k42)*h;
end
hold on
plot(x,y1,x,y2)
fprintf("TABLA-MÉTODO RK4ORDEN")
[x' y1' y2']![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1033860/image.jpeg)