sa_ex6_5.m

来自「Smart antennas for wireless communicatio」· M 代码 · 共 37 行

M
37
字号
% Fast fading with velocity  Example 6.5

N = 100;                     % number of scatterers
a=randn(N,1);              % create Gaussian amplitude coefficients
%a=a/max(a);                 % no coefficent can be larger than 1
th=rand(N,1)*2*pi;         % create uniform phase angles
ph=rand(N,1)*2*pi;
%ph=[zeros(N,1)];
fd=149;   % Doppler
%fd=250;
tmax = 10/fd;               % Maximum time
omega=2*pi*fd;      
t=[0:999]*tmax/999;   % generate timeline
Fs=length(t)/tmax;

X=[zeros(1,length(t))];
Y=[zeros(1,length(t))];
for n=1:N                   % generate the sums for X and Y
 X=X+a(n)*cos(omega*cos(th(n))*t+ph(n));
 Y=Y+a(n)*sin(omega*cos(th(n))*t+ph(n));
end
r=sqrt(X.^2+Y.^2);          %  Calculate the Rayleigh envelope
rdb=20*log10(r);            %  Calculate the envelope in dB
figure;
plot(t*1000,rdb,'k')        % plot
xlabel('time (ms)')
ylabel('envelope')
axis([0 65 -30 10])

X=[X zeros(1,2*length(X))];
Xf=fft(X);
Xf=fftshift(Xf);
NXf=length(Xf);
f=[-NXf/2+1:NXf/2]*Fs/(NXf);
figure;
plot(f,abs(Xf)/max(abs(Xf)),'k');
axis([ -Fs/40 Fs/40 0 1.2])

⌨️ 快捷键说明

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