| Contents | Index |
![]()
ezcontourf(fun)
ezcontourf(fun,domain)
ezcontourf(...,n)
ezcontourf(axes_handle,...)
h = ezcontourf(...)
ezcontourf(fun) plots the contour lines of fun(x,y)using the contourf function. fun is plotted over the default domain: -2π < x < 2π, -2π < y < 2π.
fun can be a function handle or a string (see Tips).
ezcontourf(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).
ezcontourf(...,n) plots fun over the default domain using an n-by-n grid. The default value for n is 60.
ezcontourf(axes_handle,...) plots into the axes with the handle axes_handle instead of into the current axes (gca).
h = ezcontourf(...) returns the handles to contour objects in h.
ezcontourf automatically adds a title and axis labels.
Array multiplication, division, and exponentiation are always implied in the string expression you pass to ezcontourf. For example, the MATLAB syntax for a filled contour plot of the expression
sqrt(x.^2 + y.^2);
is written as
ezcontourf('sqrt(x^2 + y^2)')
That is, x^2 is interpreted as x.^2 in the string you pass to ezcontourf.
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, ezcontourf('u^2 - v^3',[0,1],[3,6]) plots the contour lines for u2 - v3 over 0 < u < 1, 3 < v < 6.
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 ezcontourf.
fh = @(x,y) sqrt(x.^2 + y.^2); ezcontourf(fh)
When using function handles, you must use the array power, array multiplication, and array division operators (.^, .*, ./) since ezcontourf does not alter the syntax, as in the case with string inputs.
If your function has additional parameters, for example, k in myfun:
function z = myfun(x,y,k) z = x.^k - y.^k - 1;
then you can use an anonymous function to specify that parameter:
ezcontourf(@(x,y)myfun(x,y,2))
The following mathematical expression defines a function of two variables, x and y.
![]()
ezcontourf requires a string argument that expresses this function using MATLAB syntax to represent exponents, natural logs, etc. This function is represented by the string
f = @(x,y) 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 string is written on three lines and concatenated into one string using square brackets.
Pass the string variable 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)

In this particular case, the title is too long to fit at the top of the graph, so MATLAB abbreviates the string.
contourf | ezcontour | ezmesh | ezmeshc | ezplot | ezplot3 | ezpolar | ezsurf | ezsurfc | function_handle

Explore how to use MATLAB to make advancements in engineering and science.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |