plotting the histogram of data points

4 visualizzazioni (ultimi 30 giorni)
Ved il 11 Nov 2013
Commentato: Ved il 11 Nov 2013
please consider this sample code:
data = [0,2,9,2,5,8,7,3,1,9,4,3,5,8,10,0,1,2,9,5,10];
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.

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 11 Nov 2013
Modificato: Azzi Abdelmalek il 11 Nov 2013
data = [0,2,9,2,5,8,7,3,1,9,4,3,5,8,10,0,1,2,9,5,10];
y= histc(data,d)
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

Più risposte (1)

Walter Roberson
Walter Roberson il 11 Nov 2013
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).


Community Treasure Hunt

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

Start Hunting!

Translated by