Help sifting through data in a 2D matrix
Ältere Kommentare anzeigen
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
Antworten (6)
Image Analyst
am 22 Aug. 2013
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 Kommentar
Image Analyst
am 22 Aug. 2013
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
am 22 Aug. 2013
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
am 22 Aug. 2013
0 Stimmen
Kallie
am 22 Aug. 2013
0 Stimmen
Kallie
am 22 Aug. 2013
0 Stimmen
1 Kommentar
Image Analyst
am 22 Aug. 2013
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
am 23 Aug. 2013
Bearbeitet: Andrei Bobrov
am 23 Aug. 2013
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)];
Kategorien
Mehr zu Calendar finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!