フィルターのクリア

Rewrite the script and fit a 'kernel' distribution plot into a histogram

2 ビュー (過去 30 日間)
ka chun yick
ka chun yick 2020 年 3 月 9 日
編集済み: ka chun yick 2020 年 3 月 9 日
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 件)

カテゴリ

Help Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by