Data binning and frequency of data

조회 수: 2 (최근 30일)
Suresh
Suresh 2013년 8월 18일
I am having a data for example X [56 65 59 98 97 35 54 42].I want to find how many of these data points falls in a given bin range.I also have to generate bin ranges from the data X.
Bin Frequency
  • 50-55 ..... 0 % no data fall in this range
  • 55-60 ..... 3 % three points fall in this range
  • 60-65 ..... 1
  • 65-70 ..... 0.....Please help me how to do this in Matlab?

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 18일
편집: Azzi Abdelmalek 2013년 8월 18일
Edit
X= [56 65 59 98 97 35 54 42];
id=50:5:70
result=histc(X,id)
range=[id(1:end-1)' id(2:end)'];
out=[range result(1:end-1)']
  댓글 수: 2
Suresh
Suresh 2013년 8월 18일
Thank you for your answer.How to create the range (id) directly from data without manually entering id ranges.like id=min(X):5:max(X).Will it work ?
Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 18일
X= [56 65 59 98 97 35 54 42];
a=ceil(X/5)*5
id=min(a):5:max(a)
result=histc(X,id)
range=[id(1:end-1)' id(2:end)'];
out=[range result(1:end-1)']

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

추가 답변 (1개)

Image Analyst
Image Analyst 2013년 8월 18일
The histc() function is made for this exact purpose.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by