📄 pdfplot.m
字号:
% to calculate the PDF for discrete data values% use hist to collect the values belonging to a certain rangefunction [X,N,handlePDF,stats] = pdfplot(xin, nbins,nvec)% pdfplot(X, nbins) % displays a histogram of the empirical probability density function (PDF) % for the data in the input array X using nbins number of bins % (by default pdfplot sets nbins to 20).% If input X is a matrix, then pdfplot(X) parses it to the vector and % displays PDF of all values.% For complex input X, pdfplot(X) displays PDF of abs(X).%% Example:% y = randn( 1, 1e5 );% pdfplot( y );% pdfplot( y, 100 );% Version 1.0% Alex Bur-Guy, September 2003% alex@wavion.co.il%% Revisions:% Version 1.0 - initial versionif nargin == 1, nbins = 20; endxin = reshape( xin, numel(xin), 1 );if ~isreal( xin ), xin = abs( xin ); endminXin = min(xin); maxXin = max(xin); if floor( nbins ) ~= nbins, error( 'Number of bins should be integer value' ); endif nbins < 1, error( 'Number of bins should be positive integer greater than 1 ' ); endif minXin == maxXin bar(minXin,1); axis([minXin - 10, minXin + 10, 0, 1]);else step = (maxXin - minXin) / (nbins-1); binc = minXin : step : maxXin; if nargin == 3, binc = nvec; end [N, X] = hist(xin, binc); handlePDF = bar(X, N/sum(N));endxlabel('X', 'FontWeight','b','FontSize',12);title(['PDF(X) based on ' num2str(length(xin)) ' data samples @ ' num2str(nbins) ' bins'], 'FontWeight','b','FontSize',12);grid on;if nargout > 1 stats.min = min(xin); stats.max = max(xin); stats.mean = mean(xin); stats.median = median(xin); stats.std = std(xin);end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -