Help sifting through data in a 2D matrix
이전 댓글 표시
I could use some direction as to how to continue. I've got a 2D matrix, column 4 is hours, column 5 is minutes, column 6 is seconds, column 9 is data. What I need to do is sort through and create a histogram as to how often data appears during the day.
I was thinking about splitting the data in to 30 second bins, then doing the histogram with that data. But I'm a little lost as to how to step through the data chronologically and count every time data appears during each block of time.
I could use some advice, or a link to some help if you happen to know one.
Thanks -Kallie
답변 (6개)
Image Analyst
2013년 8월 22일
You can convert columns 4-6 to a serial date:
DateNumber = datenum(Y,M,D,H,MN,S) % from the help
if you want. But I don't know why that's needed. Just do a histogram of column 9 and then calculate the starting and ending time (say, it's 9 hours and 20 minutes or whatever), then divide by the elapsed time and multiply by the desired time (e.g. 24 hours) to get the count you'd have in a full 24 hours. E.g.
fullDayCounts = counts * 24 / 9.333333;
댓글 수: 1
Image Analyst
2013년 8월 22일
Regarding one of your "Answers"...
Of course that will depend on where the 30 minute block boundaries are. But you can just convert the date/time columns to serial then just run along that vector in 30 minute steps and see how many elements are less than that. Something like
countsSoFar(blockNumber) = sum(serialDate < currentTime);
Then call diff() to get the number in each 30 minute block one at a time.
dpb
2013년 8월 22일
dn=datenum(y,m,d,c(4),c(5),c(6)); % convert to datenums w/ arbitrary y,m,d
span=(dn(end)-dn(1))*86400; % time span in dataset in seconds
[n,x]=hist(c(9),ceil(span/30)); % hist over M 30-sec bins
Assumes equally spaced; if not, use the datenum vector and histc with the EDGES input vector set as 30-sec intervals.
Kallie
2013년 8월 22일
0 개 추천
댓글 수: 1
Image Analyst
2013년 8월 22일
Please add comments to someone's answer, or edit your original question. Don't keep adding additional answers (because they're not answers).
Andrei Bobrov
2013년 8월 23일
편집: Andrei Bobrov
2013년 8월 23일
Let d - your data.
[a1,i1,i1] = unique(d(:,1:3),'rows');
i2 = [true;diff(rem(d(:,4),30)) < 0];
out = [a1, accumarray(i1,i2)];
카테고리
도움말 센터 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!