problem in calculation of the mean??
2 views (last 30 days)
Show older comments
Hi all
i have a function , this function when i call it returns to me X which will be of size 55*128.i have a 18 person , for each person i have 4 images , i need to call this function for each image , so i will get the overall size of all Xs let us say M equals to 55*128*18*4(55*9216).
i need to calculate the mean of M by finding the mean of every 4 images , i mean that i need to obtain the mean of all images with a size equals to 55*128*18.(55*2304)
how can i do this? can u help me in it please??
regards
0 Comments
Answers (1)
Sargondjani
on 14 Apr 2012
you should use the 'reshape' command: transform the 'a x b x c x d' array (with d=4) into an matrix of size 'E x d' and take the mean of that.
so lets say M has dim (55,128,18,4) then reshape(M,[],4) will put all the entries of M into a (55*128*18) by 4 matrix. Taking the mean of that gives you the answer. So
Avg_4th_dim=mean(reshape(M,[],4));
Note that the 4 in the reshape command does not refer to the dimension, but size of the 4th dimension.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!