ezplot

Easy-to-use function plotter

Syntax

ezplot(fun)
ezplot(fun,[xmin,xmax])
ezplot(fun2)
ezplot(fun2,[xymin,xymax])
ezplot(fun2,[xmin,xmax,ymin,ymax])
ezplot(funx,funy)
ezplot(funx,funy,[tmin,tmax])
ezplot(...,figure_handle)
ezplot(axes_handle,...)
h = ezplot(...)

Description

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

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(...,figure_handle) plots the given function over the specified domain in the figure window identified by the handle figure.

ezplot(axes_handle,...) plots into the axes with handle axes_handle instead of the current axes (gca).

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

Examples

expand all

Plot an Explicit Function

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

ezplot('x^2')

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

Plot an Implicit Function

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

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

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

More About

expand all

Tips

Passing the Function as a String

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 string 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;
ezplot(fh)
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 string 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:

ezplot(@(x,y)myfun(x,y,2))
Was this topic helpful?