How to average array into bins (bin-averaging)

I have two arrays which I need to be the same size for further analysis. One is sediment concentration with depth, where "conc" is 253x2006 (253 depths and 2006 time points). The other is water velocity with depth, where "vel" is 6x2006 (6 depths and same 2006 time points). The depths for "vel" have a coarser resolution but they all fall within the range of the 253 finer-res depths for "conc". My problem has been trying to bin-average the concentration data to the bins of the velocity data. In other words I want to average "conc" to the same 6 bin values as "vel", with each bin centered on the original 6 depth values of "vel".
Any thoughts on how to approach this would be much appreciated! Let me know if further information is needed.

2 Comments

But 6 does not divide evenly into 253. Is that the problem?
That was definitely part of it. A simple oversight on my part. Thanks!

Sign in to comment.

Answers (1)

Matt J
Matt J on 29 Jul 2017
Edited: Matt J on 29 Jul 2017
Assuming it's a typo that conc doesn't divide evenly into 6 bins, then you could use SEPBLOCKFUN ( Download), e.g.
>> A=sepblockfun( rand(300,2006) , [50,1], @mean); Whos A
Name Size Kilobytes Class Attributes
A 6x2006 95 double

Asked:

on 28 Jul 2017

Commented:

on 3 Aug 2017

Community Treasure Hunt

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

Start Hunting!