在Matlab上以直方图拟合分布线

时间:2020-03-03 13:57:54

标签: matlab histogram probability-distribution

这是我的代码以及得到的结果。某事不正确-我使用了histfit(cntH,NumBins,'kernel'),并且我希望配电线从零开始并适合条形

我该如何解决?

clear all
clc
% yG = total 
load yH

% specify number of bins and edges of those bins; this example evenly spaces bins
NumBins = 100;
BinEdges = linspace(0,35,70);
% use histcounts and specify your bins
cntH = histcounts(yH,'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,[cntH'],'stacked')
histfit(cntH,NumBins,'kernel');
% Labels   
xlabel('Length (mm)')
ylabel('Count (log scale)')
set(gca,'YScale','log')
title('Count (log scale)')

Histogram with fitted distribution shown in red

0 个答案:

没有答案