Effacer les filtres
Effacer les filtres

Add a distribution fit in a histogram

1 vue (au cours des 30 derniers jours)
ka chun yick
ka chun yick le 12 Fév 2020
Commenté : Navya Seelam le 17 Fév 2020
Hi,
This is my script and i would like to add a distribution fit along the bars (see attachment). I assumed using the histfit() function, but i am not sure how can i do it....
% Load yA
% Load yB
% Load yC
% comment out below 3 lines and uncomment your original data loads above
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
Navya Seelam
Navya Seelam le 17 Fév 2020
Which data are you exactly trying to fit and what parameters are you trying to obtain by fitting the data?

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by