help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: reading ascii data


From: Rubén Roa-Ureta
Subject: Re: reading ascii data
Date: Tue, 05 Aug 2008 15:19:52 -0400
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

de Almeida, Valmor F. wrote:
Hello,

I would like to read an ascii data file with 3 columns of integers
separated by a space, and an unknown number of rows into 3 vectors or a
matrix with 3 columns.

I have tried
[a,b,c,count] = fscanf(fid,"%i %i %i","C");

But this only reads one row of the file and I have to put it into a
while loop with an eof check. Is this a correct assessment?

Alternatively,

[val,count] = fscanf(fid,"%i %i %i");

reads the whole file as a column vector. I could break up the vector
into 3 vectors or a matrix with 3 columns but I wonder if this could be
done by the file reader function itself.

Thanks,

--
Valmor
For this job I use load, such as in:
a = [1,2,3;4,5,6;7,8,9]
save -ascii a.txt a
b = load a.txt
b =
  1   2   3
  4   5   6
  7   8   9
HTH
Ruben


reply via email to

[Prev in Thread] Current Thread [Next in Thread]