Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab graphing/plotting problem

  1. Mar 13, 2008 #1
    1. The problem statement, all variables and given/known data

    i have 4 points,
    i want to draw a graph of this on matlab so that the first to points are joined, the last two points are joined, but i want it on the same graph.
    how do i do this? what's the command?
    thank you
  2. jcsd
  3. Mar 13, 2008 #2
    Alright, so you're learning to use Matlab... :)
    Your first two coordinates are: (8,0) and (4,-4)
    These coordinates are in the form (X,Y).
    so make an array with your X data and an array with your Y data like this:
    X1=[8 4]; Y1=[0 -4];
    Then get Matlab to plot it by using the plot command:

    Do the same for the other pair of coordinates...

    Altogether, it will look like this: (just cut and paste.. and it should work)

    X1=[8 4]; Y1=[0 -4];
    X2=[-4 -8]; Y2=[4 0];

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook