To plot a surface plot given two 2-D functions in MATLAB, we can follow these steps:
meshgrid
and z
variable to represent the function values.main.m72 chars4 lines
main.m29 chars3 lines
surf
function to plot the surface. Set the Parent
property of this function to be the newly created axes object.main.m107 chars3 lines
colorbar
, title
, and xlabel
/ylabel
/zlabel
.main.m127 chars6 lines
Here is the complete code:
main.m259 chars17 lines
This code generates a surface plot of the two functions defined by z1
and z2
.
Note that the range of x
and y
used in meshgrid
determines the domain of the functions, and the resolution of the plot is determined by the spacing used in meshgrid
.
gistlibby LogSnag