15.08.2015 Views

Introduction to the Modeling and Analysis of Complex Systems

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

introduction-to-the-modeling-and-analysis-of-complex-systems-sayama-pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.2. PHASE SPACE VISUALIZATION OF CONTINUOUS-STATE DISCRETE-TIME... 65Three-dimensional systems can also be visualized in a similar manner. For example,let’s try visualizing <strong>the</strong> following three-dimensional difference equation model:x t = 0.5x + y (5.14)y t = −0.5x + y (5.15)z t = −x − y + z (5.16)Plotting in 3-D requires an additional matplotlib component called Axes3D. A samplecode is given in Code 5.2. Note <strong>the</strong> new import Axes3D line at <strong>the</strong> beginning, as wellas <strong>the</strong> two additional lines before <strong>the</strong> for loops. This code produces <strong>the</strong> result shown inFig. 5.2.Code 5.2: phasespace-drawing-3d.pyfrom pylab import *from mpl_<strong>to</strong>olkits.mplot3d import Axes3Ddef initialize(x0, y0, z0):global x, y, z, xresult, yresult, zresultx = x0y = y0z = z0xresult = [x]yresult = [y]zresult = [z]def observe():global x, y, z, xresult, yresult, zresultxresult.append(x)yresult.append(y)zresult.append(z)def update():global x, y, z, xresult, yresult, zresultnextx = 0.5 * x + ynexty = -0.5 * x + ynextz = - x - y + zx, y, z = nextx, nexty, nextz

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!