ezcontourf
(Not recommended) Easy-to-use filled contour plotter
ezcontourf
is not recommended. Usefcontour
instead.
Syntax
ezcontourf(fun)
ezcontourf(fun,domain)
ezcontourf(...,n)
ezcontourf(axes_handle,...)
h = ezcontourf(...)
Description
ezcontourf(fun)
plots the contour lines offun(x,y)
using thecontourf
function.fun
is plotted over the default domain: -2π <x
< 2π, -2π <y
< 2π.
fun
can be a function handle, a character vector, or a string (seeTips).
ezcontourf(fun,domain)
plotsfun(x,y)
over the specifieddomain
。domain
can be either a 4-by-1 vector[xmin
,xmax
,ymin
,ymax]
or a 2-by-1 vector[min
,max]
, wheremin
<x
<max
,min
<y
<max
).
ezcontourf(...,n)
plotsfun
over the default domain using ann
-by-n
grid. The default value forn
is 60.
ezcontourf(axes_handle,...)
plots into the axes with the handleaxes_handle
instead of into the current axes (gca
).
h = ezcontourf(...)
returns the handle to a contour object inh
。
ezcontourf
automatically adds a title and axis labels.
Examples
Tips
Passing the Function as a Character Vector or String
Array multiplication, division, and exponentiation are always implied in the expression you pass toezcontourf
。例如,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 asx.^2
in the character vector or string you pass toezcontourf
。
If the function to be plotted is a function of the variablesuandv(rather thanxandy), then the domain endpointsumin
,umax
,vmin
, andvmax
are sorted alphabetically. Thus,ezcontourf('u^2 - v^3',[0,1],[3,6])
plots the contour lines foru2-v3over 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 handlefh
toezcontourf
。
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 (。^, .*, ./
) sinceezcontourf
does not alter the syntax, as in the case with character vector or string inputs.
Passing Additional Arguments
If your function has additional parameters, for example,k
inmyfun
:
function z = myfun(x,y,k) z = x.^k - y.^k - 1;
那你这n use an anonymous function to specify that parameter:
ezcontourf(@(x,y)myfun(x,y,2))