3D Plotting in Matlab
- Given two vectors describing sequences of x and y values, e.g.
- x=[1:.1:10]
- y=[-1: .01 : 1]
- the command
- [X,Y]=meshgrid(x,y)
- constructs two length(x) by length(y) matrices.
- The matrix X has the i'th value of vector x in its i'th column.
- The matrix Y has the j'th value of vector y in its j'th row.
- If the function f(x,y) is described in an m-file fcnname.m, then
- Z=fcnanme(X,Y)
- will compute an appropriate array of function values so that
- mesh(x,y,Z)
- gives a wireframe graph of f
- meshc(x,y,Z)
- gives a graph with contours drawn in the xy plane.
- surf(x,y,Z)
- gives a shaded surface representing this graph.
-
-
-
-
-
-
-
-
-
Last Update: September 25, 2000
[Mathlab Home |
Math]