0

I have a file that has the following structure

1   100
2   200
3   300
4   400

I would parse that file into two lists.

List1 would contain [1,2,3,4]

List2 would contain [100,200,300,400]

I have tried looking around but I am having trouble with the parameters to functions such as textread and fscanf. Any and all help is appreciated. Thanks!

Shai
  • 111,146
  • 38
  • 238
  • 371
bubbles
  • 861
  • 4
  • 13
  • 30
  • 3
    Relevant long-winded discussion and sample code here: http://stackoverflow.com/a/9441839/931379 – Pursuit Feb 28 '12 at 01:10
  • Voting to close, duplicate of [Fastest Matlab file reading?](http://stackoverflow.com/questions/9440592/fastest-matlab-file-reading) as Pursuit indicated. – High Performance Mark Feb 28 '12 at 10:35

1 Answers1

0

how about

fid = fopen( filename, 'r' );
[m n] = fscanf(fid, '%d %d\n');
fclose( fid );
list1 = m(1:2:end);
list2 = m(2:2:end);
Shai
  • 111,146
  • 38
  • 238
  • 371