12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

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.

We can plot the surface z as a function <strong>of</strong> x <strong>and</strong> y:mesh(x,y,z)We can exp<strong>and</strong> the domain <strong>of</strong> the calculation by increasing the inputto meshgrid. Be careful to end the lines with a semicolon to avoid beingswamped with numbers:[x,y] = meshgrid(-10:10);z = sqrt(x.^2 + y.^2);mesh(x,y,z)The surface is an inverted cone, with its apex at (0, 0, 0).Companion M-Files Feature 3 A clearer plot can be producedusing a polar grid, instead <strong>of</strong> a rectilinear grid. We can use thecompanion function polarmesh to produce such a plot. First wedefine a polar grid <strong>of</strong> points:[r,th] = meshgrid(0:.5:10,0:pi/20:2*pi);Then display the surface defined by z = r:polarmesh(r,th,r)A more interesting surface isz = 3(1 − x) 2 e −x2 −(y+1) 2 − 10( 1 5 x − x3 − y 5 )e −x2 −y 2 ···− 1 −y 23 e−(x+1)2 .In matlab notation you could type:c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!