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!