plotting the histogram of data points
조회 수: 2 (최근 30일)
이전 댓글 표시
please consider this sample code:
figure
data = [0,2,9,2,5,8,7,3,1,9,4,3,5,8,10,0,1,2,9,5,10];
hist(data)
Why this histogram plots the data points 0 & 1 with frequency 4 (on Y-axis),when in fact 0 & 1 appear two times in data.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152942/image.png)
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2013년 11월 11일
편집: Azzi Abdelmalek
2013년 11월 11일
data = [0,2,9,2,5,8,7,3,1,9,4,3,5,8,10,0,1,2,9,5,10];
d=unique(data)
y= histc(data,d)
bar(d,y)
Look at
help hist
N = hist(Y) bins the elements of Y into 10 equally spaced containers and returns the number of elements in each container
help histc
추가 답변 (1개)
Walter Roberson
2013년 11월 11일
You have 11 different values (0 through 10) but only 10 bins (default number to use if you do not specify the number in a hist() call).
댓글 수: 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!