* 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]]

posted @ 2019-03-09 11:09  kaiming_ai  阅读(179)  评论(0编辑  收藏  举报