Where in my code using runge- kutta four step method did I make a mistake?
Show older comments
% 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')
7 Comments
darova
on 10 Feb 2021
Can you show rk4singlestep function?
Charles Saulse
on 10 Feb 2021
James Tursa
on 10 Feb 2021
Edited: James Tursa
on 10 Feb 2021
Where are sigma, beta, and rho set? You need to do that before you use them in the function handle.
Can you post the complete error message, including the offending line?
Charles Saulse
on 10 Feb 2021
James Tursa
on 10 Feb 2021
Is your rk4singlestep function in a file called rk4singlestep.m?
Charles Saulse
on 11 Feb 2021
Charles Saulse
on 13 Feb 2021
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!