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 Kommentare

Matt J
Matt J am 29 Jul. 2017
But 6 does not divide evenly into 253. Is that the problem?
Kevin Simans
Kevin Simans am 3 Aug. 2017
That was definitely part of it. A simple oversight on my part. Thanks!

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 29 Jul. 2017
Bearbeitet: Matt J am 29 Jul. 2017

0 Stimmen

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

Kategorien

Gefragt:

am 28 Jul. 2017

Kommentiert:

am 3 Aug. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by