Binning CTD data into 10m intervals and corresponding data in separate columns

Hi everyone, first time posting here. I am trying to bin the following data that I have stored in a array (5026 X 6 double).
The 6 columns are the same length and contain data for: (1)time (2)pressure (3)temperature (4)salinity (5)density (6)frames/row.
I want to bin all the data into 10 meter intervals using pressure while retaining the 6 column structure. The 6th column I need to be binned into the 10m intervals as a sum.
Any suggestions would be greatly appreciated!
Thank you in advance!

 채택된 답변

Kelly Kearney
Kelly Kearney 2014년 5월 21일
편집: Kelly Kearney 2014년 5월 21일
I think pairing histc with accumarray will help:
x = rand(100,6);
x(:,1) = 1:100;
x(:,2) = sort(x(:,2))*100; % Some fake data
xbin = 0:10:100;
[n, idx] = histc(x(:,2), xbin);
sz = [max(idx) 1];
a = accumarray(idx, x(:,6), sz); % Sums by default...
b = accumarray(idx, x(:,4), sz, @mean, NaN); % or choose a different function
c = accumarray(idx, x(:,5), sz, @(x) {x}); % or gather everything

추가 답변 (1개)

I'm not sure if I understand your question. Do you need the data that are plotted by the hist function? If so,
[n,xout] = hist(...)
might be the ticket.

댓글 수: 1

Hi Chad, I rephrased the question to better communicate what I am trying to do. Hopefully its more understandable.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Oceanography and Hydrology에 대해 자세히 알아보기

질문:

2014년 5월 21일

편집:

2014년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by