Effacer les filtres
Effacer les filtres

Reading data from CSV file takes too long any suggestion ?

3 vues (au cours des 30 derniers jours)
mohsen moslemin
mohsen moslemin le 5 Sep 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

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Sep 2016
If you are using a version earlier than R2016a, then use xlsread1() from the File Exchange.
  5 commentaires
Walter Roberson
Walter Roberson le 5 Sep 2016
Sometimes the fastest approach is to read all of the data and throw away the parts you do not need.
mohsen moslemin
mohsen moslemin le 5 Sep 2016
Yes i guess you are right,

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by