C
A
R
L
O
S
|
![]() |
|||
ESTE PROGRAMA ES DESARROLLADO EN MATLAB
function RungeKutta4(f,h,y0,t0,tf) % colocar en la ventana de matlab: RungeKutta4('f',h,y0,t0,tf) % Metodo Runge-Kutta de cuarto orden para resolver una ecuacion % diferencial ordinaria de la forma: % % dy % -- = f(x,y) con condicion incial y(t0) = y0 % dx disp('-------------------------------------------------------------------') disp(' RUNGE-KUTTA DE CUARTO ORDEN ') disp('-------------------------------------------------------------------') x = t0; y = y0; Y = y'; X = x; while x<tf k1 = feval(f,x,y); k2 = feval(f,x+0.5*h,y+0.5*k1); k3 = feval(f,x+0.5*h,y+0.5*k2); k4 = feval(f,x+h,y+k3); y = y + h*(k1+2*k2+2*k3+k4)/6; x = x + h; Y = [Y;y']; X = [X;x]; end disp(' X Y'); [X Y] grid on plot(X,Y,'g') title('Runge-Kutta de cuarto orden','color','B') <> |
|
|||
![]() |