Documentation

ezsurf

Plot 3-D surface

Syntax

  • ezsurf(x,y,z)
  • ezsurf(x,y,z,[smin,smax])
  • ezsurf(x,y,z,[smin,smax,tmin,tmax]) example

Description

example

ezsurf(f) plots a two-variable symbolic expression or function f(x,y) over the range -2*pi < x < 2*pi, -2*pi < y < 2*pi.

example

ezsurf(f,[xmin,xmax]) plots f(x,y) over the specified range xmin < x < xmax. This is the range along the abscissa (horizontal axis).

example

ezsurf(f,[xmin,xmax,ymin,ymax]) plots f(x,y) over the specified ranges along the abscissa, xmin < x < xmax, and the ordinate, ymin < y < ymax.

When determining the range values, ezsurf sorts variables alphabetically. For example, ezsurf(x^2 - a^3, [0,1,3,6]) plots x^2 - a^3 over 0 < a < 1, 3 < x < 6.

ezsurf(x,y,z) plots the parametric surface x = x(s,t), y = y(s,t), z = z(s,t) over the range -2*pi < s < 2*pi, -2*pi < t < 2*pi.

ezsurf(x,y,z,[smin,smax]) plots the parametric surface x = x(s,t), y = y(s,t), z = z(s,t) over the specified range smin < s < smax.

example

ezsurf(x,y,z,[smin,smax,tmin,tmax]) plots the parametric surface x = x(s,t), y = y(s,t), z = z(s,t) over the specified ranges smin < s < smax and tmin < t < tmax.

example

ezsurf(___,n) specifies the grid. You can specify n after the input arguments in any of the previous syntaxes. By default, n = 60.

example

ezsurf(___,'circ') creates the surface plot over a disk centered on the range. You can specify'circ' after the input arguments in any of the previous syntaxes.

example

h = ezsurf(___) returns a handle h to the surface plot object. You can use the output argument h with any of the previous syntaxes.

Examples

collapse all

Plot Function Over Default Range

Plot the symbolic function f(x,y) = real(atan(x + i*y)) over the default range -2*pi < x < 2*pi, -2*pi < y < 2*pi.

Create the symbolic function.

syms f(x,y)
f(x,y) = real(atan(x + i*y));

Plot this function using ezsurf.

ezsurf(f)

Specify Plotting Ranges

Plot the symbolic expression x^2 + y^2 over the range -1 < x < 1. Because you do not specify the range for the y-axis, ezsurf chooses it automatically.

syms x y
ezsurf(x^2 + y^2, [-1, 1])

Specify the range for both axes.

ezsurf(x^2 + y^2, [-1, 1, -0.5, 1.5])

Plot Parameterized Surface

Define the parametric surface x(s,t), y(s,t), z(s,t) as follows.

syms s t
r = 2 + sin(7*s + 5*t);
x = r*cos(s)*sin(t);
y = r*sin(s)*sin(t);
z = r*cos(t);

Plot the function using ezsurf.

ezsurf(x, y, z, [0, 2*pi, 0, pi])
title('Parametric surface')

To create a smoother plot, increase the number of mesh points.

ezsurf(x, y, z, [0, 2*pi, 0, pi], 120)
title('Parametric surface with grid = 120')

Specify Disk Plotting Range

First, plot the expression sin(x^2 + y^2) over the square range -pi/2 < x < pi/2, -pi/2 < y < pi/2.

syms x y
ezsurf(sin(x^2 + y^2), [-pi/2, pi/2, -pi/2, pi/2])

Now, plot the same expression over the disk range.

ezsurf(sin(x^2 + y^2), [-pi/2, pi/2, -pi/2, pi/2],'circ')

Use Handle to Surface Plot

Plot the symbolic expression sin(x)cos(x), and assign the result to the handle h.

syms x y
h = ezsurf(sin(x)*cos(y), [-pi, pi])
h = 

  Surface with properties:

       EdgeColor: [0 0 0]
       LineStyle: '-'
       FaceColor: 'flat'
    FaceLighting: 'flat'
       FaceAlpha: 1
           XData: [60x60 double]
           YData: [60x60 double]
           ZData: [60x60 double]
           CData: [60x60 double]

  Use GET to show all properties

You can use this handle to change properties of the plot. For example, change the color of the area outline.

h.EdgeColor = 'red'
h = 

  Surface with properties:

       EdgeColor: [1 0 0]
       LineStyle: '-'
       FaceColor: 'flat'
    FaceLighting: 'flat'
       FaceAlpha: 1
           XData: [60x60 double]
           YData: [60x60 double]
           ZData: [60x60 double]
           CData: [60x60 double]

  Use GET to show all properties

Related Examples

Input Arguments

collapse all

f — Function to plotsymbolic expression with two variables | symbolic function of two variables

Function to plot, specified as a symbolic expression or function of two variables.

Example: ezsurf(x^2 + y^2)

x,y,z — Parametric function to plotthree symbolic expressions with two variables | three symbolic functions of two variables

Parametric function to plot, specified as three symbolic expressions or functions of two variables.

Example: ezsurf(s*cos(t), s*sin(t), t)

n — Grid valueinteger

Grid value, specified as an integer. The default grid value is 60.

Output Arguments

collapse all

h — Surface plot handlescalar

Surface plot handle, returned as a scalar. It is a unique identifier, which you can use to query and modify properties of the surface plot.

More About

collapse all

Tips

  • ezsurf chooses the computational grid according to the amount of variation that occurs. If f is singular for some points on the grid, then ezsurf omits these points. The value at these points is set to NaN.

Introduced before R2006a

Was this topic helpful?