* average vector from multiple files--Matlab
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;
*********
- [[https://www.mathworks.com/help/matlab/ref/sum.html?searchHighlight=sum&s_tid=doc_srchtitle][sum]]