MATLAB: Where in the code using runge- kutta four step method did I make a mistake

lorenz's parameters and rk4singlestep

% compute our trajectory
dt = .01;
tspan = 0:dt:4;
Y(:,1) = y0;
yk = y0;
for i=1:length(tspan)
time= i*dt;
ykplus1=rk4singlestep(@(t,y)lorenz(t,y,sigma,beta,rho),dt,time,yk);
Y =[Y ykplus1];
yk = ykplus1;
end
plot3(Y(1,:),Y(2,:),Y(3,:),'b')

Best Answer

Type the following at the command line:
edit rk4singlestep.m
Then copy your code into that file and save it.
Related Question