MATLAB Function Reference Previous page   Next Page
ezcontour

Easy to use contour plotter

Syntax

Description

ezcontour(fun) plots the contour lines of fun(x,y) using the contour function. fun is plotted over the default domain: -2pi < x < 2pi, -2pi < y < 2pi.

fun can be a function handle for an M-file function or an anonymous function (see Function Handles and Anonymous Functions) or a string (see the Remarks section).

ezcontour(fun,domain) plots fun(x,y) over the specified domain. domain can be either a 4-by-1 vector [xmin, xmax, ymin, ymax] or a 2-by-1 vector [min, max] (where min < x < max, min < y < max).

ezcontour(...,n) plots fun over the default domain using an n-by-n grid. The default value for n is 60.

ezcontour(axes_handle,...) plots into the axes with handle axes_handle instead of the current axes (gca).

h = ezcontour(...) returns the handles to contour objects in h.

ezcontour automatically adds a title and axis labels.

Remarks

Passing the Function as a String

Array multiplication, division, and exponentiation are always implied in the string expression you pass to ezcontour. For example, the MATLAB syntax for a contour plot of the expression

is written as

That is, x^2 is interpreted as x.^2 in the string you pass to ezcontour.

If the function to be plotted is a function of the variables u and v (rather than x and y), then the domain endpoints umin, umax, vmin, and vmax are sorted alphabetically. Thus, ezcontour('u^2 - v^3',[0,1],[3,6]) plots the contour lines for u2 - v3 over 0 < u < 1, 3 < v < 6.

Passing a Function Handle

Function handle arguments must point to functions that use MATLAB syntax. For example, the following statements define an anonymous function and pass the function handle fh to ezcontour.

Note that when using function handles, you must use the array power, array multiplication, and array division operators (.^, .*, ./) since ezcontour does not alter the syntax, as in the case with string inputs.

Passing Additional Arguments

If your function has additional parameters, for example k in myfun:

then you can use an anonymous function to specify that parameter:

Examples

The following mathematical expression defines a function of two variables, x and y.

ezcontour requires a function handle argument that expresses this function using MATLAB syntax. This example uses an anonymous function, which you can define in the command window without creating an M-File.

For convenience, this function is written on three lines. See the peaks

Pass the function handle f to ezcontour along with a domain ranging from -3 to 3 in both x and y and specify a computational grid of 49-by-49:

In this particular case, the title is too long to fit at the top of the graph, so MATLAB abbreviates the string.

See Also

contour, ezcontourf, ezmesh, ezmeshc, ezplot, ezplot3, ezpolar, ezsurf, ezsurfc, function_handle

Contour Plots for related functions


Previous page  eye ezcontourf Next page

© 1994-2005 The MathWorks, Inc.