How do I append a row average to a new matrix
1 回表示 (過去 30 日間)
古いコメントを表示
I have a 500x500 size matrix and I am trying to get the average of every 5 values in a row to make it a 100x100 matrix. How do I do that?
foo = randi(500,500)
3 件のコメント
per isakson
2021 年 2 月 22 日
編集済み: per isakson
2021 年 2 月 22 日
"every 5 values in a row" that will give you a <500x100> matrix. Do you mean: and every five values in each column? Like average of every <5x5> submatrix.
採用された回答
per isakson
2021 年 2 月 22 日
With a little bit of guessing. Does this answer your question?
%%
foo = randi(500,500);
cac = mat2cell( foo, 5*ones(100,1), 5*ones(100,1) );
num = cellfun( @(sub) mean(sub(:)), cac );
num is <100x100>
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!