raydoppler.m

来自「通信中常用瑞利衰落信道」· M 代码 · 共 29 行

M
29
字号
function [r]=ray_doppler(fm, M, dt, N)
% From: bbs.matwav.com
% Define variables:
% fm -- the maximum Doppler frequency in Hz
% M -- the number of sinusoids to generate the Rayleigh process, M > 16
% dt -- one symbol duration in second
% N -- the length of the fading sequence in symbol

T=N*dt-dt;
t=0:dt:T;
c=sqrt(2/M); % scaling factor of power
w=2*pi*fm; % maximum Doppler frequency in rad
x=0;
y=0;

for n=1:M
  alpha=(2*pi*n-pi+(2*pi*rand-pi))/(4*M);
  ph1=2*pi*rand-pi;
  ph2=2*pi*rand-pi;
  x=x+c*cos(w*t*cos(alpha)+ph1); % x-axis Gaussian process, power is 1
  y=y+c*cos(w*t*sin(alpha)+ph2); % y-axis Gaussian process, power is 1
end

% generate a complex-valued sequence
% its amplitude is Rayleigh distributed
% its angle is uniformly distributed

r=(x+sqrt(-1)*y)/sqrt(2); % normalized to the unit power

⌨️ 快捷键说明

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