⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdftest.m

📁 信道仿真的源文件
💻 M
字号:
function pdftest(r,nbins,type,mu,sigma)
% default:fit the rayleigh distribution
%type=1:Rayleigh
%type=2:Normal
%type=3:Uniform

if nargin==2
    type=1;
    mu=0;
    sigma=1;
end

%calculate the histogram 
h=hist(r,nbins);
ma=max(r);
mi=min(r);
% Finds the range of this data
range=ma-mi;
% Finds the width of each bin.
binwidth = range/nbins; 
% the horizontal coordinate
x=mi:binwidth:ma-binwidth;
%plot pdf of r
Ns=length(r);
pdf=h/Ns/binwidth;
figure;
stem(x,pdf);
hold on;
grid on;
if (type==1)
    %fit the rayleigh distribution
    %p=raylpdf(x, sqrt(2)/2);
    p=raylpdf(x ,sigma);
elseif (type==2)
    %fit the normal distribution
    p=normpdf(x,mu,sigma);
else
    p=1/(2*pi)*ones(size(x));
end
plot(x,p,'r');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -