data = randn(10000,1);
sampling = 50;
figure
[pdf_resi no] = histnorm(data, sampling, ‘plot’);%归一化之后的hist
set(gca,‘FontSize’,12,‘FontName’, ‘times new roman’);
hold on
pd = fitdist(data,‘normal’);
x_values = linspace(min(data),max(data),sampling);
y = pdf(pd,x_values);
plot(x_values,y,‘r’,‘LineWidth’,2)
legend(‘Data’,‘Norm-pdf’)
xlim([min(data) max(data)])
histnorm函数来源:
Arturo Serrano (2021). Normalized histogram (https://www.mathworks.com/matlabcentral/fileexchange/22802-normalized-histogram), MATLAB Central File Exchange. Retrieved January 1, 2021.