Element by Element Average of 100 .txt file Matrixes
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
David Hill
2020 年 4 月 21 日
A=dlmread('B00001', '',1,0);
for k=2:100;
A=A+dlmread(['B00',sprintf('%03d',k)], '',1,0);
end
A=A/100;
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!