📄 rayleigh2.m
字号:
%--------------------------------------------------------------------
% z=rayleigh2(t,fd,N,phase0)
% -------------------
% - generating multiple uncorrelated Rayleigh fading waveforms
% using the modified Jakes' model with unity variance
% - input:
% t --- a real time vector
% fd --- maximum doppler frequency in Hz
% N --- number of fading waveforms to be generated,
% it must be a power of 2.
% phase0 --- an initial phase vector with 8 elements
% when N < 8; otherwise, with N elements.
% (optional)
% - output:
% z --- a complex matrix with N columns which are
% N uncorrelated fading waveforms
% - note:
% In this program, the parameter N0 in the model is 8
% when N < 8 or N otherwise in default.
%---------------------------------------------------------------------
%---------------------------------------------------------------------
%$ generating multiple uncorrelated Rayleigh fading waveforms
% Dependencies:
% fwht.m
% Compatability:
% Matlab Ver 3.5g, Ver 4.1a
% Notes:
% References: P. Dent,"Jakes Fading Model Revisited", Electronics
% letters, 24th, June, 1993, Vol.29, No.13
%
%----------------------------------------------------------------------
function z=rayleigh2(t,fd,N,phase0)
p=log2(N)-floor(log2(N));
if p~=0
error('The third argument must be a power of 2');
elseif N < 8
N0=8;
else
N0=N;
end
M=4*N0;
wm=2.0*pi*fd;
tl=length(t);
n=1:N0;
if nargin < 4
phase0=2*pi*rand(1,N0);
end
time=(ones(N0,1)*t)';
wn=ones(tl,1)*(wm*cos(2.0*pi*(n-0.5)/M));
beta=ones(tl,1)*(pi*n/N0);
cita0=ones(tl,1)*phase0;
xc=zeros(tl,N0);
xs=xc;
y=xc;
xc=cos(beta).*cos(wn.*time+cita0);
xs=sin(beta).*cos(wn.*time+cita0);
y=sqrt(2/N0)*(xc+j*xs);
m=N0/N;
if m~=1
g=reshape(n,N,m);
y=y';
u=zeros(N,tl);
for k=1:N
u(k,:)=sum(y(g(k,:),:));
end
z=N*(fwht(u))';
else
z=N0*(fwht(y'))';
end
%Get the histograms of time difference between y(t) and y(t-1)
% Y = y(:,1) - wshift('1D',y(:,1),-1); Y(1) = []; Y = real(Y);
% Z = z(:,1) - wshift('1D',z(:,1),-1); Z(1) = []; Z = real(Z);
% subplot(2,1,1); hist(Y,50);
% subplot(2,1,2); hist(Z,50);
return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -