MATLAB: Element by Element Average of 100 .txt file Matrixes

averagematrix

I am working with 100 .txt files such as the one attached. Each file contains a matrix containing columns of X,Y,U,V. I would like to average these files element by element to construct and average matrix that can then be reshaped and plotted as seen in the code below.
Right now I am just using the large matrix from the first file which is attached below. I am trying to replace this initial matrix with the average matrix of all 100 .txt files.
All .txt files are labeled B00001, B00002, and so on. Is there anyway to read and compile all of the matrixes into a single average one?
type B00001.txt;
A=dlmread('B00001.txt', '',1,0);
X = reshape(A(:,1),124,173);
Y = reshape(A(:,2),124,173);
U = reshape(A(:,3),124,173);
V = reshape(A(:,4),124,173);
pcolor(X,Y,U);
hold on
shading interp
colormap(jet);
colorbar

Best Answer

A=dlmread('B00001', '',1,0);
for k=2:100;
A=A+dlmread(['B00',sprintf('%03d',k)], '',1,0);
end
A=A/100;