|
Luigi Giaccari wrote:
> HI i am looking for a way to count numbers of lines in a txt files. This should be usefful
> to estimate the number of points and preallocate arrays to store data. Thank you
There is no Matlab-provided function to count the number of lines in a file.
The code for counting the number of lines more or less comes down to
while true
ALine = read a line
if ALine indicates end of file, break out of the loop
increment line counter
end
Or here is an approximation that counts the number of non-empty lines in a text file:
length(textread(THEFILENAME, '%*[^\n]%c'))
--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?
|