array of mean from array

2 次查看(过去 30 天)
hi
I have a 400x400 array, and I need a new array for example a 10:10 in which the first value is the average of the first (0:40,0:40) values of the original array ... the 2:1 value is an average of the values from (41: 80,0:40) and so on until the las 10:10 values that will be the average (360:400,360:400)
I hope is clear
I can do one by one but i try to put this in a for
any sugestion please

采纳的回答

Fangjun Jiang
Fangjun Jiang 2019-10-11
a=rand(400);
b=mat2cell(a,40*ones(10,1),40*ones(1,10));
c=cellfun(@mean,b,'uni',false);
d=cellfun(@mean,c,'uni',false);
e=cell2mat(d)

更多回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019-10-11
编辑:KALYAN ACHARJYA 2019-10-11
One line with blockproc
data=magic(400);
result_mean=blockproc(data, [40 40], @(x) mean(x.data(:)));

类别

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

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by