Accelerating the pace of engineering and science

# Documentation Center

• Trial Software
• Product Updates

# 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 the handle to all the plot objects in h.

## Examples

expand all

### Plot an Explicit Function

Plot the explicit function over the domain .

ezplot('x^2')

The default domain is .

### Plot an Implicit Function

Plot the implicitly defined function over the domain .

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

The default domain is .

## More About

expand all

### 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) sqrt(x.^2 + y.^2 - 1);
ezplot(fh)
axis equal

which plots a circle. 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))

### Controlling Line Color

ezplot colors lines according to the type of graphics object it chooses to plot the input function.

• For an implicit function, ezplot uses a LineSeries object to generate the graph. To change the color, you should set the Color property.

• For an explicit function, the graph generated is a Hggroup object. So, to change the color, you should set the LineColor property.

## See Also

Was this topic helpful?