help-octave
[Top][All Lists]
Advanced

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

Re: reading data from ascii files.


From: Veloci
Subject: Re: reading data from ascii files.
Date: Fri, 16 Jul 2010 12:52:46 -0700 (PDT)

Thanks for your fast replies!

As i am currently processing the data, i've implemented some of your ideas
into code:

function
[val_max,cnt_gr_as,val_min,cnt_lw_as,val_mean,val_std,val_count,data] =
read_cal_data(filename,gr_as,lw_as)

fid = fopen(filename);

rnum = 0;
while (feof(fid)~= 1)
  rnum = rnum + 1;
  l = fgetl (fid);
end;

%allocating memory
data =zeros(rnum,4);

%range vector-[first_row,first_column,last_row,last_column]
r= [9 1 rnum-1 4];

%delimited read of the data
data = dlmread(filename,'\t',r);

val_max = max(data(:,4));
val_min = min(data(:,4));
val_mean = mean(data(:,4));
val_std = std(data(:,4));
data_size = size(data);
val_count = data_size(1,1);

%calculate border breaks
cnt_lw_as = 0;
for i = 1:val_count
if data(i,4)< lw_as
cnt_lw_as = cnt_lw_as +1;
end
end
cnt_gr_as = 0;
for i = 1:val_count
if data(i,4)>gr_as
cnt_gr_as = cnt_gr_as +1;
end
end

With that i can read the data and process it further. The thing is, dlmread
takes ages to read the data. If i reduce the amount by adjusting the range
vector (for example: r = [9 1 1000 4]) then the result is posted in an
instant. But for my files (about 300000 rows and more) there is no end to
see. 
I will try to build a loop for the dlmread procedure - pushing the data in
smaller pieces into my preallocated data matrix. I hope that will speed up
the process.

Greetings,
Veloci.  
-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/reading-data-from-ascii-files-tp2291167p2291888.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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