| | | Mesh and Surface Plots The mesh and surf commands create 3-D surface plots of matrix data. If Z is a matrix for which the elements Z(i,j ) define theheightofasurfaceoveran underlying (i,j) grid, then mesh(Z) generates a colored, wire-frame view of the surface and displays it in a 3-D view. Similarly, surf(Z) generates a colored, faceted view of the surface and displays it in a 3-D view. Ordinarily, the facets are quadrilaterals, each of which is a constant color, outlined with black mesh lines, but the shading command allows you to eliminate the mesh lines (shading flat) or to select interpolated shading across the facet (shading interp). Surface object properties provide additional control over the visual appearance of the surface. You can specify edge line styles, vertex markers, face coloring, lighting characteristics, and so on. | | |
| | | Visualizing Functions of Two Variables The first step in displaying a function of two variables, z = /Tx,y),istogenerate X and Y matrices consisting of repeated rows and columns, respectively, over thedomainofthefunction. Thenusethesematricestoevaluateandgraph the function. The meshgrid function transforms the domain specified by two vectors, x and y, into matrices X and Y. You then use these matrices to evaluate functions of two variables. The rows of X are copies of the vector x and the columns of Y are copies of the vector y. To illustrate the use of meshgrid,considerthe sin(r)/r or sine function. To evaluate this function between -8 and 8 in both x and y, you need pass only one vector argument to meshgrid, which is then used in both directions. [X,Y] = meshgrid(-8:.5:8); R = sqrt(X.A2 + Y.A2) + eps; | | |