Can any body help me in providing the code for solving the Lorenz
system by the Runge-Kutta Method in matlab:
Lorenz system is given by:
x'=a(y-x);
y'=cx-xz-y;
z'=xy-bz;
where a=10, b=8/3 and c=28
I would be very thankful for this.
Best regards,
Asim Khan
> Can any body help me in providing the code for solving the Lorenz
> system by the Runge-Kutta Method in matlab:
Use ode45. In matlab, type [t,x,y,z] = lorenz(10, 28, 8/3, 100), where the
file lorenz.m contains:
function [t, x, y, z] = lorenz(sigma, r, b, tend)
x0 = [1; 0; 0];
[t, xvec] = ode45(@f, [0, tend], x0);
x = xvec(:, 1);
y = xvec(:, 2);
z = xvec(:, 3);
% Plot of the solution
plot3(x,y,z, 'r-')
xlabel('x')
ylabel('y')
zlabel('z')
function xdot = f(t, x)
xdot= [ sigma * (x(2) - x(1)); ...
r * x(1)-x(1) * x(3) - x(2); ...
x(1) * x(2) - b * x(3) ];
end
end
HTH, Maarten
--
===================================================================
Maarten van Reeuwijk dept. of Multiscale Physics
Phd student Faculty of Applied Sciences
maarten.ws.tn.tudelft.nl Delft University of Technology