How to Plot a Function in MATLAB

Written by michael carroll
  • Share
  • Tweet
  • Share
  • Email

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.

Skill level:

Other People Are Reading


  1. 1

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


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

  2. 2

    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])

  3. 3

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

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

  4. 4

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


    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.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.