Group-wise mean in multi-dimentional array
Show older comments
I have a cell array of the dimension 1 x 121 x 515. It represents 515 sets of 1 x 121 frequency data. Since every 5 sets (along the 515) belongs in a group, I would like to take the element-wise mean of the frequency data every 5 sets (along the 515 axis). In other words, averaging the frequency data for each group so the final output will be 1x121x103. How should I do so? I tried to use the reshape feature to turn my array into 5 x 121 x 103, but the result transformation is incorrect when I compare the numbers in the pre- and post- transformed numbers.
Here is what I did:
O_npsaverageAirT=reshape(npsaverageAir,5,121,103);
I believe I can use the following to take my group-wise mean once the previous step is worked out. Is that right?
O_npsaverageAir=mean(O_npsaverageAirT,1);
I similarly have a 256*256*515 array that needs the same "average-every-5" operation along the 515-axis. I believe the solution should be similar to this one?
Thanks so much!
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!