필터 지우기
필터 지우기

Reading data from CSV file takes too long any suggestion ?

조회 수: 3 (최근 30일)
mohsen moslemin
mohsen moslemin 2016년 9월 5일
댓글: mohsen moslemin 2016년 9월 5일
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

채택된 답변

Walter Roberson
Walter Roberson 2016년 9월 5일
If you are using a version earlier than R2016a, then use xlsread1() from the File Exchange.
  댓글 수: 5
Walter Roberson
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.
mohsen moslemin
mohsen moslemin 2016년 9월 5일
Yes i guess you are right,

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by