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

MATLAB Matlab indexing within a matrx

  1. Jun 18, 2012 #1
    So I have a dataset...
    I am trying to use lets say values in column 1 to determine which values I need to plot from columns 5 and 6...
    Reading about indexing in a matrix doesn't really help as it doesn't hint at how you might use values in one column to select values from another set of columns and I'm a bit stuck.
    Any ideas?
     
  2. jcsd
  3. Jun 18, 2012 #2
    Plot column 1 with column 6:

    plot(col(:,1),col(:,6))

    Keep in mind that the two columns must have the same size.

    Matlab plots columns in a 1-1 relation, so it will plot the abscissa col(1,1) with the ordinate col(1,6), then the point (col(2,1),col(2,6)), etc.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook