Binning time-dependent data in a histogram
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (2개)
Peter Manley-Cooke
2011년 6월 28일
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
Fangjun Jiang
2011년 6월 28일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Histograms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!