Reading data from CSV file takes too long any suggestion ?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mohsen moslemin
el 5 de Sept. de 2016
Comentada: mohsen moslemin
el 5 de Sept. de 2016
clc
clear
tic
format long
files= dir('E:\PIV\*.csv');
num_files = length(files);
data_length = cell(1,num_files);
for(i=1:1:num_files);
%import all data from Column E to K
data_length{i} = xlsread(files(i).name,'E:K');
A = cell2mat(data_length);
i = 3:7:(num_files-1)*7+3;
j = 4:7:(num_files-1)*7+4;
k = sort([i j]);
%Remove two columns G and H
A(:,k)=[];
% defining mask area
r = 55/2;
p = r+2;
i = 1:5:(num_files-1)*5+1;
j = 2:5:(num_files-1)*5+2;
x = A(:,i);
y = A(:,j);
R = (x-p).^2+(y-p).^2<=r^2;
k = 5:5:(num_files-1)*5+5;
Le = A(:,k).*R;
Le(Le==0) = [];
x=A(:,i).*R;
x(x==0) = [];
y=A(:,j).*R;
y(y==0) = [];
standard_deviation_Le=std(Le);
k = 4:5:(num_files-1)*5+4;
velocity_v=A(:,k).*R;
velocity_v(velocity_v==0) = [];
positive_velocity_v=abs(velocity_v);
standard_deviation_v=std(positive_velocity_v);
k = 3:5:(num_files-1)*5+3;
velocity_u=A(:,k).*R;
velocity_u(velocity_u==0) = [];
positive_velocity_u=abs(velocity_u);
standard_deviation_u=std(positive_velocity_u);
TKE=0.5*(standard_deviation_u^2+standard_deviation_v^2+((standard_deviation_u+standard_deviation_v)/2)^2);
number=numel(x)/num_files;
%Averaging Velocity u
E=reshape(velocity_u,number,num_files);
E=E';
E=var(E);
%Averaging Velocity v
W=reshape(velocity_v,number,num_files);
W=W';
W=var(W);
%Averaging x
X=reshape(x,number,num_files);
X=X';
X=mean(X);
%Averaging y
Y=reshape(y,number,num_files);
Y=Y';
Y=mean(Y);
scale_factor = 0.1;
figure
quiver(X,Y,E*scale_factor,W*scale_factor,'AutoScale','off')
end
0 comentarios
Respuesta aceptada
Walter Roberson
el 5 de Sept. de 2016
5 comentarios
Walter Roberson
el 5 de Sept. de 2016
Sometimes the fastest approach is to read all of the data and throw away the parts you do not need.
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!