Rewrite the script and fit a 'kernel' distribution plot into a histogram
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
This is my script. I am trying to it a 'kernel' distribution plot into an existing histogram. So, how can i do that and which line should i add to the script? Or how to re-write the script? P.S. the 'yG' is the data from excel. Do i need to use the 'stacked' function in the bar(b,[cntG'], 'stacked') if i only got one group of data. I think i have made my script too complicated.....
% yG = total
load yG
% specify number of bins and edges of those bins; this example evenly spaces bins
NumBins = 100;
BinEdges = linspace(0,35,70);
% use histcounts and specify your bins
cntG = histcounts(yG,'BinEdges',BinEdges);
% plot
figure(1); cla; hold on;
% convert bin edges into bin centers
b = BinEdges(1:end-1)+diff(BinEdges)/2
% use bar
bar(b,[cntG'],'stacked')
% Labels
xlabel('Length(mm)')
ylabel('Count')
댓글 수: 0
답변 (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!