Binning time-dependent data in a histogram
2 views (last 30 days)
Show older comments
So, my data looks something like this: t1 = (1, 5, 8, 9), t2 = (2, 7, 9, 12), t3 = (2, 5, 5)
Each of the values is a datapoint; I'm measuring the time when the datapoint occured (so, in t1, datapoint 2 is occuring at timepoint 5s for example).
I want to combine all trails in one histogram, whos x-axis are timebins, so that I know how many datapoints I have at timepoint 2 sec, taken all the trails together.
So far, I put all my trails in one structure, but I can't get them aligned so that I can compute how many datapoints I have for a certain timepoint. I hope someone can help. It's driving me crazy, that I can't figure it out. :(
0 Comments
Answers (2)
Peter Manley-Cooke
on 28 Jun 2011
If the data is in vectors, then
t1 = [1 5 8 9];
t2 = [2 7 9 12];
t3 = [2 5 5];
% Combine the data
t= [t1 t2 t3];
% put it in a histogram
hist(t,max(t));
% or collect data about the histogram
[N B] = hist(t,max(t));
will show a histogram with seconds on the x axis. As shown in the documentation, N is the number of items in each bin and B is the value of the bin centre.
0 Comments
Fangjun Jiang
on 28 Jun 2011
I don't understand. The code below shows a histogram. It shows at time t=2 and t=5, there are 3 data points. At time t=9, there are two data points. The rest, there is one data points. Is this what you want? Or you just couldn't get structure data together? What does your structure data look like?
t1=[1 5 8 9];
t2=[2 7 9 12];
t3=[ 2 5 5];
t=[t1 t2 t3];
hist(t);
0 Comments
See Also
Categories
Find more on Histograms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!