I have this code for Runge Kutta method and keep showing error "index must be a positive interger " please I need help
Afficher commentaires plus anciens
%Script that demonstrates the Runge-Kutta integration for a first order problem %the problem to be solved is: %f(xi,yi)=(1/2)-xi+2*yi h=0.2; %h is the time step. y0=1; yi=y0; xf=0.2; x0=0; xi=x0; n=xf-x0/xf; %iterate for i=0:n f(xi,yi)=(1/2)-xi+2*yi; k1=f(xi,yi)*h; k2=f(xi+(h/2),yi+h/2*k1); k3=f(xi+h/2,yi+(h/2)*k2); k4=f(xi+h,yi+h*k3); y(i+1)=yi+(1/6)*(k1+2*k2+2*k3+k4); x(i+1)=xi+h;
end
y(i+1)
x(i+1)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur General Physics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!