How do I get the same bin width for two different data sets using the histfit command?
Afficher commentaires plus anciens
I have a problem with the bin widths in the histfit command: I want to compare two lognorm-distributed data sets with different sample sizes (A is a 530x1 array, B is a 335x1 array), so I created a histogram with using the hisfit command with normalized data. The code I used:
h1=histfit(A,30,'lognorm')
hold on
h2=histfit(B,24,'lognorm')
%Generating normalized data
N1=sum(h1(1).YData);
N2=sum(h2(1).YData);
h1(1).YData=h1(1).YData/N1;
h1(2).YData=h1(2).YData/N1;
h2(1).YData=h2(1).YData/N2;
h2(2).YData=h2(2).YData/N2;
alpha(h1(1),.5)
alpha(h2(1),.5)
uistack(h1(2),'top')
uistack(h2(2),'top')
xlim([0 3000])
ylim([0 0.2])
hold off
This code gives me the following Histogram:

As you can see, the bin width is not the same for both data sets. Does anybody know a method to generate a histogram with two normalized data sets, the lognorm fits and the same bin widths?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Descriptive Statistics 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!