This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


(Not recommended) Easy-to-use function plotter

ezplot is not recommended. Use fplot instead.


h = ezplot(...)


ezplot(fun) plots the expression fun(x) over the default domain -2π < x < 2π, where fun(x) is an explicit function of only x.

fun can be a function handle or a character vector.

ezplot(fun,[xmin,xmax]) plots fun(x) over the domain: xmin < x < xmax.

For an implicit function, fun2(x,y):

ezplot(fun2) plots fun2(x,y) = 0 over the default domain -2π < x < 2π, -2π < y < 2π.

ezplot(fun2,[xymin,xymax]) plots fun2(x,y) = 0 over xymin < x < xymax and xymin < y < xymax.

ezplot(fun2,[xmin,xmax,ymin,ymax]) plots fun2(x,y) = 0 over xmin < x < xmax and ymin < y < ymax.

ezplot(funx,funy) plots the parametrically defined planar curve funx(t) and funy(t) over the default domain 0 < t < 2π.

ezplot(funx,funy,[tmin,tmax]) plots funx(t) and funy(t) over tmin < t < tmax.

ezplot(...,fig) plots into the figure window identified by fig. Use any of the input argument combinations in the previous syntaxes that include a domain. The domain options are [xmin xmax], [xymin xymax], [xmin xmax ymin ymax], and [tmin tmax].

ezplot(ax,...) plots into the axes ax instead of the current axes (gca).

h = ezplot(...) returns either a chart line or contour object.


collapse all

Plot the explicit function $x^2$ over the domain $[-2\pi,2\pi]$.


The default domain is $[-2\pi,2\pi]$.

Plot the implicitly defined function $x^2-y^4 = 0$ over the domain $[-2\pi,2\pi]$.


The default domain is $[-2\pi,2\pi]$.

More About

collapse all


Passing the Function as a Character Vector

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

x.^2 - y.^2

which represents an implicitly defined function, is written as

ezplot('x^2 - y^2')

That is, x^2 is interpreted as x.^2 in the character vector you pass to ezplot.

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 ezplot.

fh = @(x,y) x.^2 + y.^3 - 2*y - 1;
axis equal

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

Passing Additional Arguments

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:


See Also

| | | | |

Introduced before R2006a

Was this topic helpful?