Element by Element Average of 100 .txt file Matrixes
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
David Hill
am 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;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!