Code covered by the BSD License  

Highlights from
Numerical Computing with Simulink, Vol. 1

image thumbnail
from Numerical Computing with Simulink, Vol. 1 by Richard Gran
This sequel to Numerical Computing with MATLAB explores the mathematics of simulation.

Lorenz_eigs.m
%  This m-file creates the root locus for the Lorenz Chaos model.
%  It requires data that is generated when you run the model
%  Lorenz_2.mdl that is in this directory.  The model generates 
%  a set of linear models that are stored in MATLAB structures.
%  
%  The A-matrix for the ith linearized state-space model is:
%       Lorenz_2_Trigger_Based_Linearization_(i).a
%
%  We creater a structure in MATLAB called Lorenz.eig.  Lorenz is a 40 by 1
%  structure with the substructure eig a 3 vector that has the three
%  eigenvalues at each of the time points represented by i.  In the
%  simulaiton of the Lorenz attractor, the linear models were created every
%  1/50 of a second, so Lorenz_2_Trigger_Based_Linearization_(i).a is of
%  dimension 1000.  We calculate the eigenvalues for every 50th of these,
%  so the eignevalues are for the linear models created every 1 second.
%  You can change this by changing the number 50 in the for loop.  You can
%  also go back to the model and change the Pulse Generator block times for
%  the Trigger Based Linearization block to chnage the number of linear
%  models that are created.

% Note -- Every time you run the Lorenz_2 model, a different set of initial
% conditions is used, so the resulting eigenvalues will be different.

axis([-25 15 -25 25]);
axis('square')
grid
hold on
nlins = tstop/0.01;

for i = 1:nlins/50
    Lorenz(i).eig=eig(Lorenz_2_Trigger_Based_Linearization_(i).a);
    plot(real(Lorenz(i).eig),imag(Lorenz(i).eig),'.')
    drawnow
end
hold off

Contact us at files@mathworks.com