Matlab: Lorenz Attractor

I’m a big fan of the Lorenz Attractor, which, when plotted, resembles the half open wings of a butterfly. This attractor was derived from a simplified model of convection in the earth’s atmosphere. One simple version of the Lorenz attractor is pictured below:

The Lorentz system is a set of ordinary differential equations notable for its chaotic solutions (see below).  Here $x$, $y$ and $z$ make up the system state, $t$ is time, and $sigma, row, beta$ are the system parameters.

The Lorentz attractor is a chaotic solution to this system found when $row = 28, sigma = 10. beta = 8/3$.

The series does not form limit cycles nor does it ever reach a steady state.

We can calculate and render the aforementioned chaotic solution to this ODE as follows:

function loren3
global A B R 
A = 10; 
B = 8/3; 
R = 28; 
u0 = 100*(rand(3,1) - 0.5); 
[t,u] = ode45(@lor2,[0,100],u0); 
N = find(t>10); v = u(N,:);

x = v(:,1);
y = v(:,2);
z = v(:,3);

view(158, 14)

function uprime = lor2(t,u) 

global A B R 
uprime = zeros(3,1); 
uprime(1) = -A*u(1) + A*u(2); 
uprime(2) = R*u(1) - u(2) - u(1)*u(3); 
uprime(3) = -B*u(3) + u(1)*u(2);

This results in the figure:

To create a surface/mesh from this line plot, we proceed…

One thought on “Matlab: Lorenz Attractor”

Leave a Reply

Your email address will not be published. Required fields are marked *