help-octave
[Top][All Lists]
Advanced

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

Re: how to know number of lines from input file


From: febty febriani
Subject: Re: how to know number of lines from input file
Date: Wed, 7 Oct 2009 17:15:56 +0900

thanks very much for your response. but when wrote lixe below ;

fh=fopen("$dir/data-1day-1Hz/result-${year}${month}${num}.dat","r");
y=fscanf(fh,"%lf",[N, inf]);

without any definitons of N, I met an error message that I must define N.

I tried to define N by writing N=number lines of data before fh so my script will be:

N=number
fh=fopen("$dir/data-1day-1Hz/result-${year}${month}${num}.dat","r");
y=fscanf(fh,"%lf");

but it didn't work.
any suggestions are appreciated.
Thanks very much.


best regards,
febty


2009/10/7 Søren Hauberg <address@hidden>
ons, 07 10 2009 kl. 11:56 +0900, skrev febty febriani:
> If I have command like below :
>
> fh=fopen("$dir/data-1day-1Hz/result-${year}${month}${num}.dat","r");
> y=fscanf(fh,"%lf");
>
> are there any tricks to know number of lines from the input file?

If your file only contains numbers, then you can just use the 'load'
command, which will give you a neatly formated matrix.

If you know the number of numbers in each line, then you can also do
something like

 y = fscanf (fh, "%lf", [N, Inf])

where N is the number of numbers per line.

Søren




--

******
febty febriani
Indonesian Institute of Sciences
Research Center for Physics
Kompleks PUSPIPTEK
Serpong, Indonesia, 15314

reply via email to

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