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

Respuestas (6)

Image Analyst
Image Analyst el 22 de Ag. de 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 comentario

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.

Iniciar sesión para comentar.

dpb
dpb el 22 de Ag. de 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
Kallie el 22 de Ag. de 2013

0 votos

So column 9 is just data. Numbers that really have no impact on the histogram. Really, I just need to determine how many times there is data over a 24 hour period in 30 minute blocks.
There are over 78,000 line items in this data set.
Kallie
Kallie el 22 de Ag. de 2013

0 votos

It should note that the seconds are down to 5 decimal places also.
Kallie
Kallie el 22 de Ag. de 2013

0 votos

Example of from the file. http://tinypic.com/r/2usbyhf/5

1 comentario

Image Analyst
Image Analyst el 22 de Ag. de 2013
Please add comments to someone's answer, or edit your original question. Don't keep adding additional answers (because they're not answers).

Iniciar sesión para comentar.

Andrei Bobrov
Andrei Bobrov el 23 de Ag. de 2013
Editada: Andrei Bobrov el 23 de Ag. de 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)];

Categorías

Etiquetas

Preguntada:

el 22 de Ag. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by