average column data from multiple files
example
in file a, data is [1 , 2, 3; 4,5,6]
file b, data is [4,5, 6; 7,8,9]
average=0.5 (a+b)
matlab code
n=359; a=[]; b=[]; c=[]; % for loop for i=1:n filename=sprintf('output_%d.dat',i); fileinfo = importdata(filename); ux=fileinfo.data(:,7); % extract column data uy=fileinfo.data(:,8); uz=fileinfo.data(:,9); a=[a,ux]; % put all Ux in an array b=[b,uy]; c=[c,uz]; end aver_Ux=sum(a,2)/n; % sum of array elements aver_Uy=sum(b,2)/n; aver_Uz=sum(c,2)/n;