필터 지우기
필터 지우기

Binning time-dependent data in a histogram

조회 수: 4 (최근 30일)
Mary
Mary 2011년 6월 28일
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. :(

답변 (2개)

Peter Manley-Cooke
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.

Fangjun Jiang
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);

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by