MATLAB For Dummies
Book image
Explore Book Buy On Amazon

MATLAB provides the EZPlot method of working with formulas to help you easily see how the formula looks graphically without taking a lot of time to do it. With this approach, you can focus on refining the formula results rather than the associated plot. The plotting time is negligible. The disadvantage of this approach is that it lacks flexibility. Yes, you can use it to create a quick plot for a report, but if you want the best possible presentation, you need to use more sophisticated plotting techniques.

The following steps demonstrate how to use an EZPlot for a basic plotting need:

  1. Open your copy of MATLAB.

    You see the MATLAB application start with the Command window displayed.


  2. Type format compact and press Enter.

    MATLAB displays the output of anything you type using the compact format, which means without any added whitespace. Notice the use of color coding. The command is in black type; the argument is in purple. Color coding helps you understand the MATLAB input with greater ease.


  3. Type ezplot('sin(x)', [-pi, pi]) and press Enter.

    The ezplot() function produces the actual plot. The 'sin(x)' argument is the function you want ezplot() to plot. The [-pi, pi] vector contains the upper and lower limits of the plot.


  4. Type hold on and press Enter.

    MATLAB places a hold on the current figure.


  5. Type ezplot('cos(x)', [-pi, pi]) and press Enter.

    You see the cos() function output added to the sin() function output because the plot has a hold placed on it.


  6. Type hold off and press Enter.

    MATLAB removes the hold on the current figure.


  7. Close your copy of MATLAB.

About This Article

This article is from the book:

About the book authors:

John Paul Mueller is an author and technical editor with experience in application development, database management, machine learning, and deep learning. He has written hundreds of books and articles helping everyday people learn everything from networking to database management.

John Mueller has published more than 100 books on technology, data, and programming. John has a website and blog where he writes articles on technology and offers assistance alongside his published books.

Luca Massaron is a data scientist specializing in insurance and finance. A Google Developer Expert in machine learning, he has been involved in quantitative analysis and algorithms since 2000.

This article can be found in the category: