# How to Plot a Function in MATLAB

Save

MATLAB is a digital tool, and as such can only work with finite subsets of the domains and ranges of real functions. However, like graphing calculators and other software tools, MATLAB is fully capable of calculating enough data points you can produce a representation of a continuous function of sufficient precision for nearly any qualitative evaluation of its properties. Use the "ezplot" function to quickly create a plot of a function in MATLAB.

• Type the "ezplot" command, supplying the function to be plotted as a string that MATLAB can parse:

ezplot('sin(x)')

The plot appears in a new window. The graph's bounds are automatically determined.

• Specify the region of the function's domain to be plotted by adding a vector as the second argument to "ezplot":

ezplot('sin(x)',[-pi pi])

• Specify the range to be plotted as well by using a four-element vector:

ezplot('sin(x)',[-pi pi -1 1])

• Graph a parametric equation by passing the two functions of the parameter as separate arguments to "ezplot":

ezplot('sin(t)','cos(t)')

This is equivalent to plotting the following set of parametric equations:

x = sin(t)

y = cos(t)

Specify the values of the parameter to be plotted by supplying a vector as the third argument, just as in Step 2.

## References

Promoted By Zergnet

## Related Searches

Check It Out

### Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!