Skip to main content
infervour.com

Back to all posts

How to Plot A Simple Graph In MATLAB?

Published on
6 min read
How to Plot A Simple Graph In MATLAB? image

Best Graph Plotting Tools to Buy in October 2025

1 KOALA TOOLS | Isometric Graph Paper Notebook (1 Unit) | 7.5" x 9.75", 60 pp. - Kraft Cover Isometric Grid Drawing Pads - Suitable for Industrial, Architectural, Interior Design

KOALA TOOLS | Isometric Graph Paper Notebook (1 Unit) | 7.5" x 9.75", 60 pp. - Kraft Cover Isometric Grid Drawing Pads - Suitable for Industrial, Architectural, Interior Design

  • CREATE STUNNING 3D RENDERINGS WITH OUR ISOMETRIC GRAPH PAPER.
  • TRAVEL-FRIENDLY DESIGN: COMPACT, FLAT-LAYING, 60 DOUBLE-SIDED PAGES.
  • DURABLE 80 GSM PAPER WITHSTANDS HIGH-PRESSURE DRAFTING EFFORTLESSLY.
BUY & SAVE
$8.97
KOALA TOOLS | Isometric Graph Paper Notebook (1 Unit) | 7.5" x 9.75", 60 pp. - Kraft Cover Isometric Grid Drawing Pads - Suitable for Industrial, Architectural, Interior Design
2 DIGITAL IMAGE PROCESSING USING MATL

DIGITAL IMAGE PROCESSING USING MATL

  • 130 NEW PROJECTS ENHANCE CLASSROOM LEARNING AND PRACTICAL USAGE.

  • COMPREHENSIVE SUPPORT PACKAGE WITH CODE AND SOLUTIONS INCLUDED.

  • IN-DEPTH COVERAGE OF DEEP LEARNING AND MODERN IMAGE PROCESSING TECHNIQUES.

BUY & SAVE
$168.00
DIGITAL IMAGE PROCESSING USING MATL
3 The Scientist & Engineer's Guide to Digital Signal Processing

The Scientist & Engineer's Guide to Digital Signal Processing

  • AFFORDABLE PRICES ON HIGH-QUALITY PRE-OWNED BOOKS.
  • THOROUGHLY CHECKED FOR QUALITY, ENSURING READER SATISFACTION.
  • ECO-FRIENDLY CHOICE: REDUCE WASTE BY BUYING USED BOOKS.
BUY & SAVE
$63.05
The Scientist & Engineer's Guide to Digital Signal Processing
4 Essential MATLAB for Engineers and Scientists

Essential MATLAB for Engineers and Scientists

BUY & SAVE
$37.72
Essential MATLAB for Engineers and Scientists
5 Koala Tools | Geometric Grid Transparency Sheets (Variety Pack of 4) - 11" x 17" | Overhead Projector and Light Box Transparencies - Tracing Film for Sketching & Drawing

Koala Tools | Geometric Grid Transparency Sheets (Variety Pack of 4) - 11" x 17" | Overhead Projector and Light Box Transparencies - Tracing Film for Sketching & Drawing

  • FOUR GRAPH CONFIGURATIONS FOR DIVERSE DRAWING NEEDS!
  • EASILY COMPATIBLE WITH LIGHT BOXES AND PROJECTORS!
  • REUSABLE PVC FILM FOR ENDLESS CREATIVE POSSIBILITIES!
BUY & SAVE
$22.97
Koala Tools | Geometric Grid Transparency Sheets (Variety Pack of 4) - 11" x 17" | Overhead Projector and Light Box Transparencies - Tracing Film for Sketching & Drawing
6 Nicpro 30PCS Professional Drafting Tools & Geometry Set with Case, Architect Protractor Set, Metal Mechanical Pencils, Pen, Scale Ruler Metal Ruler, 5 Drawing Templates for Interior Design House Plan

Nicpro 30PCS Professional Drafting Tools & Geometry Set with Case, Architect Protractor Set, Metal Mechanical Pencils, Pen, Scale Ruler Metal Ruler, 5 Drawing Templates for Interior Design House Plan

  • 30 PCS KIT: COMPREHENSIVE TOOLS FOR PRECISE DRAFTING AND DESIGN WORK.
  • DURABLE TEMPLATES: 5 REUSABLE TEMPLATES FOR EFFICIENT, CREATIVE DESIGNS.
  • PORTABLE CASE: ORGANIZED STORAGE FOR EASY ACCESS AND TRAVEL CONVENIENCE.
BUY & SAVE
$28.99 $32.99
Save 12%
Nicpro 30PCS Professional Drafting Tools & Geometry Set with Case, Architect Protractor Set, Metal Mechanical Pencils, Pen, Scale Ruler Metal Ruler, 5 Drawing Templates for Interior Design House Plan
7 SCRIBBLEDO Isometric Grid 11"x14" Large Graph Dry Erase Board Double-Sided White Board Drawing Grid Lines Graphing Architectural Gridded 3D Design Whiteboard for Home School Classroom

SCRIBBLEDO Isometric Grid 11"x14" Large Graph Dry Erase Board Double-Sided White Board Drawing Grid Lines Graphing Architectural Gridded 3D Design Whiteboard for Home School Classroom

  • DOUBLE-SIDED DESIGN: CHOOSE BETWEEN GRID AND BLANK SURFACES!
  • VERSATILE TOOL: PERFECT FOR ART, MATH, AND SCIENCE LESSONS!
  • ECO-FRIENDLY: REDUCE PAPER WASTE WITH DRY-ERASE FUNCTIONALITY!
BUY & SAVE
$7.98 $9.99
Save 20%
SCRIBBLEDO Isometric Grid 11"x14" Large Graph Dry Erase Board Double-Sided White Board Drawing Grid Lines Graphing Architectural Gridded 3D Design Whiteboard for Home School Classroom
8 Mr. Pen- Professional Geometry Set, 15 pcs, Geometry Kit for Artists and Students, Geometry Set, Metal Rulers and Compasses, Drawing Tools, Drafting Supplies, Drafting Set, Drafting Tools and Kits

Mr. Pen- Professional Geometry Set, 15 pcs, Geometry Kit for Artists and Students, Geometry Set, Metal Rulers and Compasses, Drawing Tools, Drafting Supplies, Drafting Set, Drafting Tools and Kits

  • COMPLETE GEOMETRY SET: ALL ESSENTIAL TOOLS FOR MATH AND DESIGN.
  • DURABLE CASE INCLUDED: KEEP TOOLS ORGANIZED AND PROTECTED ON THE GO.
  • IDEAL FOR ALL USERS: PERFECT FOR STUDENTS, TEACHERS, AND PROFESSIONALS ALIKE.
BUY & SAVE
$19.85
Mr. Pen- Professional Geometry Set, 15 pcs, Geometry Kit for Artists and Students, Geometry Set, Metal Rulers and Compasses, Drawing Tools, Drafting Supplies, Drafting Set, Drafting Tools and Kits
9 Koala Tools - 40-Sheet Sketch Pad for 2-Point Perspective Drawing, Spiral Bound Gridded Graph Paper for Interior Room Design, Industrial, Architectural and 3D Design, 11 x 14 inches

Koala Tools - 40-Sheet Sketch Pad for 2-Point Perspective Drawing, Spiral Bound Gridded Graph Paper for Interior Room Design, Industrial, Architectural and 3D Design, 11 x 14 inches

  • MAKE SKETCHING FUN: ENJOY EFFORTLESS 3D DRAWING WITH PERSPECTIVE GRIDS!

  • PERFECT PERSPECTIVE: CREATE STUNNING SCENES FOR COMICS AND DESIGNS EASILY.

  • DURABLE & HIGH QUALITY: 40 MICRO-PERFORATED SHEETS FOR INTENSE DRAWING SESSIONS.

BUY & SAVE
$19.95
Koala Tools - 40-Sheet Sketch Pad for 2-Point Perspective Drawing, Spiral Bound Gridded Graph Paper for Interior Room Design, Industrial, Architectural and 3D Design, 11 x 14 inches
10 Koala Tools - 40-Page Drawing Pad for 2-Point Perspective, Room Grid Sketch Pad with 3D Virtual Walls Design, Gridded Graph Paper for Interior Room Design, Industrial, Architectural 11 x 17 inches

Koala Tools - 40-Page Drawing Pad for 2-Point Perspective, Room Grid Sketch Pad with 3D Virtual Walls Design, Gridded Graph Paper for Interior Room Design, Industrial, Architectural 11 x 17 inches

  • DRAW REALISTIC INTERIORS WITH OUR 1-POINT PERSPECTIVE GRID DESIGN!
  • PERFECT FOR HOBBYISTS CREATING COMICS AND ANIME-STYLE SCENES.
  • EASY-TO-TEAR 40-SHEET PAD WITH STURDY 80GSM KRAFT PAPER.
BUY & SAVE
$16.95
Koala Tools - 40-Page Drawing Pad for 2-Point Perspective, Room Grid Sketch Pad with 3D Virtual Walls Design, Gridded Graph Paper for Interior Room Design, Industrial, Architectural 11 x 17 inches
+
ONE MORE?

To plot a simple graph in MATLAB, you can follow these steps:

  1. Open MATLAB and create a new script file.
  2. Define the x-values and corresponding y-values that you want to plot. For example, you can create two vectors x and y to represent the x and y coordinates of the graph points.
  3. Plot the graph using the plot() function. Specify the x-values as the first input and the y-values as the second input. For instance, use plot(x, y) to plot the graph.
  4. Customize the graph if desired. You can add a title to the graph using title(), label the x and y-axis with xlabel() and ylabel(), respectively. You can also add a grid with grid on to make it easier to interpret the graph.
  5. Display the legend if you have multiple graphs on the same plot. You can specify the legend entries as input arguments to the legend() function.
  6. Save the graph as an image file, if necessary. You can use the saveas() function and provide a filename and desired file format (e.g., PNG, JPEG) as arguments.

Once you have completed these steps, you can run the script and a new figure window will open with the plotted graph.

How to plot a surface plot in MATLAB?

To plot a surface plot in MATLAB, you can use the "surf" function. Here are the steps:

  1. Define the x, y, and z data. The x data represents the x-coordinates, the y data represents the y-coordinates, and the z data represents the corresponding values at each (x, y) point.
  2. Use the "meshgrid" function to create a grid of x and y values from their respective vectors. This will create 2D arrays for x and y.
  3. Use the "meshgrid" output arrays and the z data to create a mesh or grid of (x, y, z) values using the "surf" function. The "surf" function will generate a 3D surface plot.
  4. Customize the plot appearance by adding axis labels, a title, and adjusting the viewing angle if desired.

Here is an example code:

% Step 1: Define x, y, and z data x = linspace(-5, 5, 100); y = linspace(-5, 5, 100); [X, Y] = meshgrid(x, y); Z = sinc(sqrt(X.^2 + Y.^2)); % Example z data

% Step 2: Create the grid [X, Y] = meshgrid(x, y);

% Step 3: Create the surface plot surf(X, Y, Z);

% Step 4: Customize plot appearance xlabel('X'); ylabel('Y'); zlabel('Z'); title('Surface Plot'); view(3); % Adjust viewing angle (optional)

This code will create a surface plot of the "sinc" function in a grid spanned by the x and y values. Remember to modify the x, y, and z data according to your specific application or dataset.

How to add gridlines to a MATLAB plot?

To add gridlines to a MATLAB plot, you can use the grid function. Here's how you can do it:

  1. Generate some data and create a plot:

x = 1:10; y = x.^2; plot(x, y);

  1. Use the grid function to add gridlines:

grid on;

By default, this will add both horizontal and vertical gridlines to the plot. If you want to add only horizontal or only vertical gridlines, you can modify the grid function as follows:

  • To add only horizontal gridlines: grid on; grid minor;
  • To add only vertical gridlines: grid on; grid minor on;

How to plot error bars in MATLAB?

To plot error bars in MATLAB, you can use the errorbar function. The syntax for errorbar is as follows:

errorbar(x, y, y_error)

Where:

  • x is a vector of x-axis values
  • y is a vector of y-axis values
  • y_error is a vector of the same length as y, representing the magnitude of the errors

Here is an example to demonstrate how to use errorbar function:

x = 1:5; % x-axis values y = [3 5 2 7 4]; % y-axis values y_error = [0.4 0.9 0.3 0.6 0.5]; % error values

errorbar(x, y, y_error) xlabel('X') ylabel('Y') title('Error bars')

This code will plot a line graph with error bars representing the uncertainty in the y-axis values. The xlabel, ylabel, and title functions are used to add labels and a title to the plot.

How to label the x-axis in a MATLAB plot?

To label the x-axis in a MATLAB plot, you can use the xlabel function. Here is an example:

% Create some data x = 1:10; y = rand(1, 10);

% Plot the data plot(x, y)

% Label the x-axis xlabel('X-axis label')

In this example, the xlabel function is used to provide the label for the x-axis. You can replace 'X-axis label' with your desired label.

How to plot a 3D graph in MATLAB?

To plot a 3D graph in MATLAB, you can use the plot3 function or the surf function. Here are the steps for each method:

  1. Using plot3 function: a. Define your x, y, and z data as vectors. b. Call the plot3 function and pass your x, y, and z data as arguments. c. Customize your plot with optional arguments like color and marker type. For example: x = linspace(-5, 5, 100); y = linspace(-5, 5, 100); [X, Y] = meshgrid(x, y); % Convert x and y to a grid Z = sin(sqrt(X.^2 + Y.^2)); plot3(X(:), Y(:), Z(:), 'r-'); % Plot 3D graph xlabel('X'); ylabel('Y'); zlabel('Z');
  2. Using surf function: a. Define your x and y data as matrices using the meshgrid function. b. Define your z data as a corresponding matrix. c. Call the surf function and pass your x, y, and z data as arguments. d. Customize your plot with optional arguments like color and shading. For example: x = linspace(-5, 5, 100); y = linspace(-5, 5, 100); [X, Y] = meshgrid(x, y); % Convert x and y to a grid Z = sin(sqrt(X.^2 + Y.^2)); surf(X, Y, Z); % Plot 3D graph xlabel('X'); ylabel('Y'); zlabel('Z'); colormap(jet); % Set color map shading interp; % Smooth shading colorbar; % Show color bar

These are the basic steps to plot a 3D graph in MATLAB. You can further customize your plots by changing axes limits, adding titles, legends, etc., based on your requirements.