0

I am trying to convert data that I have in my .txt file( few lines below):

nodeID, ts, in_pkts, out_pkts, in_links, out_links

1, 1, 0, 0, 0, 0

1, 2, 2, 2, 0, 0

1, 3, 1, 13, 0, 0

1, 4, 1, 8, 0, 0

1, 5, 1, 2, 0, 0

I would like to get values from the secon column as x, and third as y and then use plot(x,y) to get a figure. I thought about using the read function but how could I get just second and third column.

Thank you

Community
  • 1
  • 1
marcin
  • 67
  • 1
  • 2
  • 9

1 Answers1

1

https://stackoverflow.com/a/25214848/901925 has a more complicated case of reading a text file with Octave.

I think your case can be handled with csvread (among others). It will give you a matrix, from which you can select the desired columns.

octave:3> x=csvread('stack25230911.txt')
x =

    0    0    0    0    0    0
    1    1    0    0    0    0
    1    2    2    2    0    0
    1    3    1   13    0    0
    1    4    1    8    0    0
    1    5    1    2    0    0

octave:8> x=M(2:end,2);
octave:9> y=M(2:end,3);
octave:10> plot(x,y)
Community
  • 1
  • 1
hpaulj
  • 221,503
  • 14
  • 230
  • 353