Main Content

ezsurf

(Not recommended) Easy-to-use 3-D colored surface plotter

    ezsurf is not recommended. Use fsurf instead. For more information, see Version History.

    Description

    ezsurf(f) creates a surface plot of the function f(x,y) using the surf function. The function plots f over the default interval [-2π 2π] for x and y.

    ezsurf automatically adds a title and axis labels to the plot.

    example

    ezsurf(f,xyinterval) plots over the specified interval.

    ezsurf(funx,funy,funz) plots the parametric surface funx(u,v), funy(u,v), and funz(u,v) over the default interval [-2π 2π] for u and v.

    ezsurf(funx,funy,funz,uvinterval) plots the parametric surface using the specified interval.

    ezsurf(___,n) plots using an n-by-n grid. Use this option after any of the input argument combinations in the previous syntaxes.

    ezsurf(___,'circ') plots over a disk centered on the interval.

    ezsurf(ax,___) plots into the axes specified by ax instead of the current axes. Specify the axes before any of the input argument combinations in any of the previous syntaxes.

    s = ezsurf(___) returns the chart surface object. Use s to modify the surface after it is created. For a list of properties, see Surface Properties.

    Examples

    collapse all

    Plot the function f(x,y)=real(atan(x+iy)) over the domain -2π<x<2π and -2π<y<2π. The ezsurf function does not plot points where the mathematical function is not defined. These points are set to NaN so that they do not plot.

    figure
    ezsurf('real(atan(x+i*y))')

    Figure contains an axes object. The axes object with title real ( atan ( x + i blank y )), xlabel x, ylabel y contains an object of type surface.

    Use surf to plot the same data without filtering discontinuities.

    figure
    [x,y] = meshgrid(linspace(-2*pi,2*pi,60));
    z = real(atan(x+1i.*y));
    surf(x,y,z)

    Figure contains an axes object. The axes object contains an object of type surface.

    Input Arguments

    collapse all

    3-D function to plot, specified as a character vector, string scalar, or function handle to a named or anonymous function.

    Specify a function of the form z = f(x,y). The function must accept two matrix input arguments and return a matrix output argument of the same size.

    When specifying the function as a character vector or string scalar, array multiplication, division, and exponentiation are always implied. For example, x^2 is interpreted as x.^2.

    Example: 'sqrt(x^2 + y^2)'

    When specifying the function as a function handle, use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

    Example: @(x,y) sin(x).*cos(y)

    Plotting interval for x and y, specified in one of these forms:

    • Vector of form [min max] — Use the interval [min max] for both x and y.

    • Vector of form [xmin xmax ymin ymax] — Use the interval [xmin xmax] for x and [ymin ymax] for y.

    Parametric function for x coordinates, specified as a character vector, string scalar, or function handle to a named or anonymous function.

    Specify a function of the form x = funx(u,v). The function must accept two matrix input arguments and return a matrix output argument of the same size.

    When specifying the function as a character vector or string scalar, array multiplication, division, and exponentiation are always implied. For example, x^2 is interpreted as x.^2.

    Example: 'u*sin(v)'

    When specifying the function as a function handle, use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

    Example: @(u,v) u.*sin(v)

    Parametric function for y coordinates, specified as a character vector, string scalar, or function handle to a named or anonymous function.

    Specify a function of the form y = funy(u,v). The function must accept two matrix input arguments and return a matrix output argument of the same size.

    When specifying the function as a character vector or string scalar, array multiplication, division, and exponentiation are always implied. For example, x^2 is interpreted as x.^2.

    Example: '-u*cos(v)'

    When specifying the function as a function handle, use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

    Example: @(u,v) -u.*cos(v)

    Parametric function for z coordinates, specified as a character vector, string scalar, or function handle to a named or anonymous function.

    Specify a function of the form z = funz(u,v). The function must accept two matrix input arguments and return a matrix output argument of the same size.

    When specifying the function as a character vector or string scalar, array multiplication, division, and exponentiation are always implied. For example, x^2 is interpreted as x.^2.

    Example: '-u*cos(v)'

    When specifying the function as a function handle, use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

    Example: @(u,v) v

    Plotting interval for u and v, specified in one of these forms:

    • Vector of form [min max] — Use the interval [min max] for both u and v.

    • Vector of form [umin umax vmin vmax] — Use the interval [umin umax] for u and [vmin vmax] for v.

    Size of the grid, specified as a positive integer. The grid has dimensions n-by-n.

    Axes object. If you do not specify an axes object, then ezsurf uses the current axes.

    Extended Capabilities

    Version History

    Introduced before R2006a

    collapse all

    R2016a: ezsurf is not recommended

    ezsurf is not recommended. Use fsurf instead. There are no plans to remove ezsurf.

    fsurf requires that the input function to plot is a function handle. ezsurf accepts either a function handle, a character vector, or a string. This table shows some typical usages of ezsurf and how to update your code to use fsurf instead.

    Not RecommendedRecommended
    ezsurf('real(atan(x+i*y))')fsurf(@(x,y) real(atan(x+i*y)))
    ezsurf('sin(x)+cos(y)')fsurf(@(x,y) sin(x)+cos(y))
    ezsurf(@(x,y) sqrt(x.^2+y.^2))fsurf(@(x,y) sqrt(x.^2+y.^2))