rayleigh_1.m

来自「通信系统中基于MATLAB的四相移相键控调制的仿真」· M 代码 · 共 91 行

M
91
字号
% BERFADING Bit error rate (BER) for Rayleigh fading channels.
% RAYLEIGHCHAN   Construct a Rayleigh fading channel object.
% commblkfadingchan2.m: % COMMBLKFADINGCHAN Rayleigh/Rician channel helper function.
% commblkrayleighchan2.m: % COMMBLKRAYLEIGHCHAN Rayleigh channel helper function.
% COMMBLKRAYLEIGHSRC2 Mask dynamic dialog function for Rayleigh source block.
%  COMMBLKFADINGCHAN Rayleigh/Rician channel helper function.
%  COMMBLKRAYLEIGHCHAN Rayleigh channel helper function.
%  COMMBLKRAYLEIGHSRC Mask dynamic dialog function for Rayleigh source block
% RAYLCDF  Rayleigh cumulative distribution function.
% RAYLFIT Parameter estimates and confidence intervals for Rayleigh data.
% RAYLINV  Inverse of the Rayleigh cumulative distribution function (cdf).
% RAYLPDF  Rayleigh probability density function.
% RAYLRND Random arrays from the Rayleigh distribution.
% RAYLSTAT Mean and variance for the Rayleigh distribution.
%--------------------------
% x = 0:0.1:3;
% p = raylcdf(x,inf);
% plot(x,p)
% %--------------------------
% c1 = rayleighchan(1e-5,130) % Create object.
% c1.PathDelays = [0 1e-6] % Change the number of delays.
% The output displays all the properties of the channel object before and after the change in the value of the PathDelays property. 
% Notice that in the second listing of properties, the AvgPathGaindB, PathGains, and ChannelFilterDelay properties all have different values 
% compared to the first listing of properties
%---------------------------------------------
%以下是rayleigh信道的实现
%1*1信道
% randn is a normal distribution with mean zero, variance one and standard
% deviation one.sigmax=sigmay=1
x=randn;
y=randn;
% c=x+i*y;
r=(x^2+y^2)^0.5;
theta=atan(y/x);
p=r*exp(j*theta);
%r*c信道
r=3;
c=2;
x_1=randn(r,c);
y_1=randn(r,c);
% c_1=x_1+i*y_1;
r_1=(x_1.^2+y_1.^2).^0.5;
theta_1=atan(y_1./x_1);
p_1=r_1.*exp(j*theta_1);
%rayleigh distribution
r=0:0.1:100;
sigma=10;
pr=r/sigma^2.*exp(-r.^2/(2*sigma^2));%包络概率密度函数
ptheta=0.5/pi;%相位概率密度函数
m=(pi/2)^0.5*sigma;%均值
E=2*sigma^2;%均方值
figure(1)
plot(r/sigma,pr)
%验证构造信道
r_1=1;
c_1=1000;
x_2=randn(r_1,c_1);
y_2=randn(r_1,c_1);
% c_1=x_1+i*y_1;
r_2=(x_2.^2+y_2.^2).^0.5;
theta_2=atan(y_2./x_2);
p_2=r_2.*exp(j*theta_2);
m_1=mean(r_2);
sigma=1;%sigma=sigmax=sigmay=1
delta=m_1-(pi/2)^0.5*sigma %验证均值
a=max(r_2);
b=min(r_2);
x=0:0.1:5;%要求b<5
f=zeros(1,50);
%有没有不用循环的方法??
for i=1:50
    for j=1:1000
        if 0.1*(i-1)<=r_2(j)&r_2(j)<0.1*i
            f(i)=f(i)+1;
        end
    end
end
f=f/sum(f);
figure(2)
bar(f)










⌨️ 快捷键说明

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