This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
gibson:teaching:fall-2014:math445:lecture16-diary [2014/11/18 07:24] gibson |
gibson:teaching:fall-2014:math445:lecture16-diary [2014/11/18 07:25] (current) gibson [surf, surfc] |
||
|---|---|---|---|
| Line 89: | Line 89: | ||
| The previous plots were all looking straight down at the (x,y) plane, with the value of z = f(x,y) encoded as a color. The ''surf'' function will plot z = f(x,y) in 3D, as a surface of height z over the (x,y) plane. | The previous plots were all looking straight down at the (x,y) plane, with the value of z = f(x,y) encoded as a color. The ''surf'' function will plot z = f(x,y) in 3D, as a surface of height z over the (x,y) plane. | ||
| + | <code matlab> | ||
| surf(X,Y,Z) % draw z=f(x,y) as a surface over x,y | surf(X,Y,Z) % draw z=f(x,y) as a surface over x,y | ||
| xlabel('x'); ylabel('y'); zlabel('z') | xlabel('x'); ylabel('y'); zlabel('z') | ||
| axis equal; axis tight | axis equal; axis tight | ||
| + | </code> | ||
| It's also possible to draw more complicated surfaces (surfaces that are not simple graphs of the form | It's also possible to draw more complicated surfaces (surfaces that are not simple graphs of the form | ||
| Line 116: | Line 118: | ||
| - | % quiver plot | ||
| - | % used to show vector fields | ||
| - | load y.asc | ||
| - | load x.asc | ||
| - | load vx.asc | ||
| - | load vy.asc | ||
| - | clf() | ||
| - | quiver(x,y,vx,vy); | ||
| - | axis equal | ||
| - | axis tight | ||
| - | xlabel('x'); ylabel('y'); | ||
| - | title('vector field vx,vy over plane x,y') | ||
| - | |||
| - | |||
| - | % subplots | ||
| - | % make an array of plots within a figure window | ||
| - | clf() | ||
| - | subplot(2,2,1) % 1st subplot in 2 x 2 array | ||
| - | quiver(x,y,vx,vy); | ||
| - | axis equal | ||
| - | axis tight | ||
| - | subplot(2,2,2) % 2nd subplot in 2 x 2 array | ||
| - | surfc(X,Y,Z,C); axis equal | ||
| - | subplot(2,2,3) % 2nd subplot in 2 x 2 array | ||
| - | surf(X,Y,Z,Z); axis equal | ||
| - | subplot(2,2,4) % 4th | ||
| - | x = linspace(0,pi,20); | ||