Azzera filtri
Azzera filtri

Add a distribution fit in a histogram

1 visualizzazione (ultimi 30 giorni)
ka chun yick
ka chun yick il 12 Feb 2020
Commentato: Navya Seelam il 17 Feb 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 Commento
Navya Seelam
Navya Seelam il 17 Feb 2020
Which data are you exactly trying to fit and what parameters are you trying to obtain by fitting the data?

Accedi per commentare.

Risposte (0)

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by