Thursday, September 24, 2009

Modal Decomposition

Modal decomposition constructs a similarity transformation for a linear system where the resulting coefficient matrix is a block diagonal structure corresponding to the real and complex eigenvalues. See problem 4.14 of Astrom and Murray for a description of the transformed coefficient matrix.  The download ModelDemo.zip contains a Matlab function modal.m to compute the modal decomposition for an arbitrary coefficient matrix, and a function ModalDemo.m to illustrate the application to a randomly 3D linear system.

Wednesday, September 23, 2009

Eigen Decomposition of Linear Systems

One of the basic tools for understanding linear, time-invariant systems is the 'modal' decomposition on to a set of 'eigendirections'.  This is illustrated in the matlab files in the Eigen Decomposition Demo download.



Run the script S_EigenDemo.m to create versions of the plot shown above. The script selects random eigenvectors and assigns eigenvalues for a 3D system, then calls a function to superimpose a trajectory over a representation of the eigendirections.

To test your understanding, try the following exercises:
  1. Change the real parts of the eigenvalues to obtain other types of behavior.  What happens if you make the real eigenvalue much more negative, or slightly positive? What happens if you make the real part of the complex conjugate pair slightly positive?
  2. How can you make the simulated trajectory orbit the real eigenvector in a plane parallel to the other two eigendirections?

Lorenz Attractor

The Lorenz attractor is a well known system of three differential equations demonstrating deterministic chaos.  The model was originally derived by Edward Lorenz as an abstract description for convection rolls in the atmosphere, but is mainly studied for the insight it gives on the behavior of complex deterministic systems.



Download run the Matlab function LorenzDemo. Rotate and manipulate the resulting figure in phase space, and be sure you understand what is going on.  To test your understanding, modify this function to plot two trajectories on the same axis that start at nearby initial conditions, say less than 0.00001 apart. What happens to the trajectories over time?

Hare and Lynx Demonstration

The dynamics of the Hare and Lynx predator/prey system provides a very useful illustration of phase plane analysis for a system of two ordinary differential equations. The textbook includes a discussion of this example in Section 3.7

Under the downloads you will find a link to a compressed folder holding with Matlab and Simulink files for demonstrating the Hare/Lynx dynamics. The files include a Simulink model, and a separate Matlab script with which you can explore this system.




The qualitative concepts you should learn from this example include
  • Phase plane modeling in Simulink and Matlab
  • Time invariant differential equations as vector fields in phase space.
  • Nullclines, Steady States, and Limit Cycles
  • Linearization
  • Global versus local stability
To test your understanding, consider the following questions:
  1. What do the three steady states represent in terms of the Hare/Lynx populations?
  2. Repeat the simulations setting the parameter b = 0.26. How do the results change?
  3. Repeat again for b = 0.20.  What happened to the third steady state? Interpret this in terms of the Hare/Lynx population dynamics.
  4. What is the critical value of b for which a limit cycle first appears?
  5. What is the critical value of b for which the linear approximation first exhibits complex eigenvalues? How do you interpret this situation?

Saving Matlab figures as pdf's

You'll often see me use the function fig4pdf in the Matlab scripts for this course. This function makes it easier to save Matlab figures as nicely formatted pdf files that can be included in reports and presentations. It sets the background color and paper dimensions to produce what -- to my eyes -- is a visually pleasing result with properly cropped borders.  To use it in your own Matlab programming, just include the function call

fig4pdf;

at some point in the process of preparing a figure.  It will have no visual effect on the figure window. Later, when you want to actually save the figure as a pdf file, use the function call

print('-dpdf','r1200', 'myfigure.pdf');

where myfigure.pdf is the desired file name.  Alternatively, you can format and save the figure in one step with the function call

fig4pdf(gcf,'myfigure.pdf');

where gcf refers to the current figure. Because I use fig4pdf in so many of demonstration scripts for this course, you may want to download and store this file in your default Matlab folder.