C
A
R
L
O
S
|
![]() |
|||
ESTE PROGRAMA ES DESARROLLADO CON MATLAB
function RungeKutta3(f,h,y0,t0,tf) % colocar en la ventana de matlab: RungeKutta3('f',h,y0,t0,tf) % Metodo Runge-Kutta de tercer 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 TERCER 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*h); k3 = feval(f,x+h,y-k1*h+2*k2*h); y = y + h*(k1+4*k2+k3)/6; x = x + h; Y = [Y;y']; X = [X;x]; end disp(' X Y'); [X Y] grid on plot(X,Y,'r') title('Runge-Kutta de tercer orden','color','B') <> |
|
|||
![]() |