Borrar filtros
Borrar filtros

Add a distribution fit in a histogram

1 visualización (últimos 30 días)
ka chun yick
ka chun yick el 12 de Feb. de 2020
Comentada: Navya Seelam el 17 de Feb. de 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 comentario
Navya Seelam
Navya Seelam el 17 de Feb. de 2020
Which data are you exactly trying to fit and what parameters are you trying to obtain by fitting the data?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by