Lorenz Chaos
Posted: Wed Feb 20, 2013 7:14 pm
I wrote this Matlab script of Lorenz's chaos for an assignment. Save as lorenz.m to run [NOTE: If you want to use GNU Octave, then the two functions must be split into two files, lorenz.m and Lchaos.m]
The equations are as follows:
x' = s(y - x)
y' = x(t - z) - y
z' = xy - bz
For (5,5,5) as the initial conditions, as set in the code above, these two plots struck me as being particularly neat:
The equations are as follows:
x' = s(y - x)
y' = x(t - z) - y
z' = xy - bz
Code: Select all
% HW 4 Problem 1 - Lorenz Chaos
%-------------------------------------------------------
function lorenz;
[t x] = ode45(@Lchaos,[0 50],[5;5;5]); % Initial conditions are the last matrix.
figure(1)
plot(t,x(:,1)),xlabel('t'),ylabel('x'),title('x(t)')
figure(2)
plot(t,x(:,2)),xlabel('t'),ylabel('y'),title('y(t)')
figure(3)
plot(t,x(:,3)),xlabel('t'),ylabel('z'),title('z(t)')
figure(4)
plot(t,x),xlabel('t'),ylabel('x,y,z'),legend('x(t)','y(t)','z(t)')
figure(5)
plot(x(:,1),x(:,2)),xlabel('x'),ylabel('y'),title('xy Phase Plane')
figure(6)
plot(x(:,1),x(:,3)),xlabel('x'),ylabel('z'),title('xz Phase Plane')
figure(7)
plot(x(:,2),x(:,3)),xlabel('y'),ylabel('z'),title('yz Phase Plane')
figure(8)
plot3(x(:,1),x(:,2),x(:,3)),xlabel('x'),ylabel('y'),zlabel('z')
function xprime = Lchaos(t,x);
sig = 10;,tau = 28;,bet = 8/3; % PARAMETERS -- THESE AND INITIAL CONDITIONS CAN BE ADJUSTED
xprime = zeros(3,1);
xprime(1) = sig*(x(2) - x(1));
xprime(2) = x(1)*(tau - x(3)) - x(2);
xprime(3) = x(1)*x(2) - bet*x(3);