Fitting a curve to a histogram
Afficher commentaires plus anciens
Hi,
This is my current script. I would like to fit a curve to a histogram as shown in the picture below: What lines should i add to the existing script?

yA = randn(1000,1)*7+15;
yB = randn(1000,1)*3+7;
yC = randn(1000,1)*4+30;
% specify number of bins and edges of those bins; this example evenly spaces bins
NumBins = 25;
BinEdges = linspace(0,50,25);
% use histcounts and specify your bins
cntA = histcounts(yA,'BinEdges',BinEdges);
cntB = histcounts(yB,'BinEdges',BinEdges);
cntC = histcounts(yC,'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,[cntA',cntB',cntC'],'stacked')
1 commentaire
chi qiu
le 30 Sep 2020
Hey, did you find a way??
Réponses (2)
KALYAN ACHARJYA
le 13 Fév 2020
ka chun yick
le 14 Fév 2020
Modifié(e) : ka chun yick
le 14 Fév 2020
Catégories
En savoir plus sur Histograms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
