Histogram using MAX not frequency values within a Bin?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tyson Haniotis
am 9 Sep. 2017
Bearbeitet: Tyson Haniotis
am 27 Sep. 2017
Hi, I can't seem to find anywhere how to make a histogram using the max values within a binwidth (like a bar graph) instead everything on the internet appears to show frequency histogram.
Thanks,
Regards, Tyson.
1 Kommentar
Stephen23
am 9 Sep. 2017
Bearbeitet: Stephen23
am 9 Sep. 2017
"Histogram using MAX not frequency values within a Bin?"
The reason why you will not find anything on the internet is because what you are searching for makes no sense: a histogram is by definition a bar graph of the frequencies, so searching for a histogram using max is going to find you as many results as searching for a monotonically increasing sinewave or a circle with five corners.
Histogram, noun:
Are you really asking about how to create a bar chart with binned data?
Akzeptierte Antwort
Stephen23
am 9 Sep. 2017
Bearbeitet: Stephen23
am 9 Sep. 2017
One way would be to assign the values to groups using bsxfun and then use accumarray to get the maximum of each group:
>> x = [-5,-4,-3,-2,-1,0,1,2,3,4,5,6];
>> y = [ 6, 5, 4, 3, 1,1,1,3,4,5,6,7];
>> bw = 2;
>> bx = x(1):bw:x(end)+bw;
>> cn = sum(bsxfun(@le,bx(:),x),1);
>> mx = accumarray(cn(:),y(:),[],@max)
mx =
6
4
1
3
5
7
>> bar(mx)
giving:

0 Kommentare
Weitere Antworten (1)
Image Analyst
am 9 Sep. 2017
Are you looking for the bar() function instead of histogram()?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Histograms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!