Reading data from CSV file takes too long any suggestion ?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2016년 9월 5일
댓글 수: 5
Walter Roberson
2016년 9월 5일
Sometimes the fastest approach is to read all of the data and throw away the parts you do not need.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!