How to Connect Points in MATLAB

Written by sean hill
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Connect Points in MATLAB
Learn how to plot a line between two points in Matlab. (Ryan McVay/Photodisc/Getty Images)

Matlab is a programming language that allows users to enter, manipulate, plot and analyse data in a variety of ways. Matlab's built-in graphing utility, the "plot" function, can yield a graph of a set of points and also can draw lines between these points. Once you have plotted a set of points, invoke the plot function again with the specific data points you want to connect.

Skill level:
Moderately Easy

Other People Are Reading

Things you need

  • Matlab R2006 or later version

Show MoreHide

Instructions

  1. 1

    Open Matlab. Plot the data that contain the points you want to connect. Use the "Plot" function.

  2. 2

    Identify the x-coordinates of the two points you want to connect. Type "x = [x1, x2]" in the command window. For example, if you want to connect (1,5) and (3,6), type "x = [1,3]."

  3. 3

    Identify the y-coordinates of the two points you want to connect, and type "y = [y1,y2]" in the command window. For example, if you want to connect (1,5) and (3,6), type "y = [5,6]."

  4. 4

    Type "plot(x,y)" in the command window to connect the two points.

Tips and warnings

  • To plot the whole set of data, type "plot(X,Y)" in the command window. "X" should be a set of x-coordinates. "Y" should be a set of y-coordinates.
  • If you want to connect more points, repeat steps 3, 4, and 5 with new points.

Don't Miss

Filter:
  • All types
  • Articles
  • Slideshows
  • Videos
Sort:
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

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