Contenido principal

ezcontourf

(Not recommended) Filled contour plotter

ezcontourf is not recommended. Use fcontour instead.

Description

ezcontourf(f) plots the contour lines of f(x,y), where f is a sym 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® software 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.

ezcontourf automatically adds a title and axis labels.

ezcontourf(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, ezcontourf(u^2 - v^3,[0,1],[3,6]) plots the contour lines for u2 - v3 over 0 < u < 1, 3 < v < 6.

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

Examples

Plot Filled Contours

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

f(x,y)=3(1x)2ex2(y+1)210(x5x3y5)ex2y213e(x+1)2y2.

ezcontourf requires a sym argument that expresses this function using MATLAB syntax to represent exponents, natural logs, etc. This function is represented by the symbolic expression

syms x y
f = 3*(1-x)^2*exp(-(x^2)-(y+1)^2)... 
   - 10*(x/5 - x^3 - y^5)*exp(-x^2-y^2)... 
   - 1/3*exp(-(x+1)^2 - y^2);

For convenience, this expression is written on three lines.

Pass the sym f to ezcontourf along with a domain ranging from -3 to 3 and specify a grid of 49-by-49.

ezcontourf(f,[-3,3],49)

Figure contains an axes object. The axes object with title 3 blank exp (- blank ( y blank + blank 1 ) Squared baseline blank - blank x Squared baseline ) blank ( x blank - blank 1 ) Squared baseline blank -...+ blank exp (- blank x Squared baseline blank - blank y Squared baseline ) blank ( 10 blank x Cubed baseline blank - blank 2 blank x blank + blank 10 blank y toThePowerOf 5 baseline ), xlabel x, ylabel y contains an object of type contour.

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

Input Arguments

collapse all

Input, specified as a symbolic function or expression.

Domain to plot over, specified as a symbolic vector. domain is 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

Grid points, specified as a number or a symbolic number.

Version History

Introduced before R2006a