MATLAB frequency histogram problem

Hey everybody,
I'm having trouble recreating a frequency histogram. The data are exported from an external software as ASCII. Any help is appreciated! This is how it looks: The program returns two column vectors. One vectors contains the occurance/frequency (e.g. 2;0;1 ..), the other the already binned observation (e.g. distances like 150;150.5;151 ..). What I'd like to do now is to generate a vector containing just the (binned) data. According to the above example: (150;150;151). I already tried some loops (though it didn't work and I don't have them at hand right now - there has to be an easy solution for it). One more thing: If I rehistrogram the data with Matlab, will it change the binsize due to the absence of the value 150.5 as mentioned above? Though this should have no effect on the mean? Thanks a lot!
Phil

댓글 수: 4

Image Analyst
Image Analyst 2014년 8월 18일
What do you mean by "already binned observation"? Let's say you have a million numbers and 100 bins. So you have the counts in one column vector, and the million numbers in the other column vector, but are they the original values? Or the "already binned observation" - whatever that means (I have no idea)? Attaching your data file would help.
Phil
Phil 2014년 8월 18일
PreviewDisable
"So you have the counts in one column vector, and the million numbers in the other column vector, but are they the original values?"
Thanks for your answer. Sorry for not explaining this better, you are definately right. One vector contains the counts, the other the bins. Will attach the file as soon as I get back to the other computer!
Image Analyst
Image Analyst 2014년 8월 18일
Do you mean the values of the centers of the bins? Like let's say one bin goes from 150.0000000 to 151.00000000. Would the value you're talking about be 150.5 (i.e. the value at the center of the bin)?
Phil
Phil 2014년 8월 19일
I'm pretty sure it's the central value of each bin since the difference (binsize) is constant over all values. Attached please find the example.

댓글을 달려면 로그인하십시오.

답변 (1개)

Phil
Phil 2014년 8월 19일
편집: Image Analyst 2014년 8월 19일

0 개 추천

Ok, worked it out. Fairly simple.
function histogram(bins,counts)
outvec = [];
for i = 1:length(counts)
if counts(i,1) ~= 0
for n = 1:counts(i,1)
outvec = [outvec bins(i,1)];
end
else
end
end
outvec = outvec*10^9;
hist(outvec, length(bins))
end

카테고리

도움말 센터File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

질문:

2014년 8월 18일

편집:

2014년 8월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by