I need to solve the equation presented on the code with those initial condition, integration step and interval.
I am with this code at the moment and I need to create a loop.
On the commented section there's a code I found for two variables but I don't know to make it just for one. Can someone please explain?
I just started with MATLAB and Runge-Kutta so any help would be greatly appreciated.
clear; clch=0.1; tinitial=1; tfinal=5;y(0)=1;f=@(y) (1-2*y)*y^2%rk4 loop - found this code for two variables and tested
%for i=1:ceil(tfinal/h)
%update y
% k1=f(y(i));
% k2=f(t(i)+0.5*h,y(i)+0.5*k1*h);
% k3=f(t(i)+0.5*h,y(i)+0.5*k2*h);
% k4=f(t(i)+ h,y(i)+ k3*h);
% y(i+1)=y(i)+h/6*(k1 + 2*k2 + 2*k3 + k4);
%end
Best Answer