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
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by