How do I get the same bin width for two different data sets using the histfit command?
이전 댓글 표시
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?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Half-Normal Distribution에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!