Element by Element Average of 100 .txt file Matrixes
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
David Hill
on 21 Apr 2020
A=dlmread('B00001', '',1,0);
for k=2:100;
A=A+dlmread(['B00',sprintf('%03d',k)], '',1,0);
end
A=A/100;
More Answers (0)
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!