[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fscanf
From: |
Joao Cardoso |
Subject: |
Re: fscanf |
Date: |
Wed, 14 Apr 1999 16:28:28 +0100 |
Thomas Walter wrote:
>
> >>>>> "Joao" == Joao Cardoso <address@hidden> writes:
>
> Joao> Thomas Walter wrote:
> >>
> >> Hello,
> >> is it only me who has problems with 'fscanf' and friends?
> >>
> >> I have measured data in a data file written as ASCII, i.e.:
> >> 10 123.4
> >> 20 234.5
> >> 30 345.6
> >> 40 456.7
> >> 50 567.8
> >> 60 678.9
> >>
> >> This is data in one line belongs together. In this case I have 2
> >> columns and the number of lines/rows is unknown, bu defined by EOF.
> >> If I read the data with this knowledge I always jump into the same
> >> pit. The 'fscanf' function wants lines and colomuns in the opposited
> >> order.
> >>
> >> Apart from that the matrix I get has the size 2x6, this means:
> >> 10 20 30 40 50 60
> >> 123.4 234.5 345.6 456.7 567.8 678.9
> >>
> >> Is this behaviour only strange for me?
It seems that the doc is not updated.
a=fscanf(f,"%f",[2, inf])' do what you want, I guess, but does not do
the same thing as
a=fscanf(f,"%f",2)' as the online help suggests:
NR : read as much as possible, returning a matrix with NR rows
[NR, Inf] : same as NR
octave:54> a=fscanf(f,"%g",[2,inf])
a =
10.000 20.000 30.000 40.000 50.000 60.000
123.400 234.500 345.600 456.700 567.800 678.900
ans = 0
octave:55> a=fscanf(f,"%g",[2])
a =
10.000
123.400
ans = 0
--
Joao Cardoso | e-mail: address@hidden
INESC, R. Jose Falcao 110 | tel: + 351 2 2094322
4050 Porto, Portugal | fax: + 351 2 2008487
- fscanf, Thomas Walter, 1999/04/13