MATLAB Function Reference    

Easy to use contour plotter



ezcontour(f) plots the contour lines of f(x,y), where f is a string that represents a mathematical function of two variables, such as x and y.

The function f is plotted over the default domain: -2 < x < 2, -2 < y < 2. MATLAB chooses the computational grid according to the amount of variation that occurs; if the function f is not defined (singular) for points on the grid, then these points are not plotted.

ezcontour(f,domain) plots f(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).

If f 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.

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

ezcontour automatically adds a title and axis labels.


Array multiplication, division, and exponentiation are always implied in the 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.


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

ezcontour requires a string argument that expresses this function using MATLAB syntax to represent exponents, natural logs, etc. This function is represented by the string:

For convenience, this string is written on three lines and concatenated into one string using square brackets.

Pass the string variable f to ezcontour along with a domain ranging from -3 to 3 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

Contour Plots for related functions

  eye ezcontourf