📄 fading_eigen.m
字号:
% Generating correlated fading using eigen values
%%%%% While this process is simple, generating the eigen values is
%%%%% computationaly intensive in Matlab which makes the simulation rather
%%%%% slow
clear all;
close all;
%Specified variables.
NumberSamples =1024; % Number of samples of the random process
fdTs = 0.01; % The normalized Doppler rate
% Generate desired covariance matrix:
Cyy = zeros( NumberSamples, NumberSamples );
for i=1:NumberSamples
for k=1:NumberSamples
Cyy(i,k) = 0.5*besselj( 0, 2*pi*fdTs*abs(k-i) ); % This is also the desired auto correlation.
end
end
% Now find the transformation matrix
[P,Lambda] = eig( Cyy );
A = P*sqrt(Lambda);
% Now generate a Rayleigh faded vector
% start with vectors of independent Gaussian variables
x_real = randn(NumberSamples,1);
x_imag = randn(NumberSamples,1);
% Now "color" the vectors (i.e. make correlated)
y_real = A*x_real;
y_imag = A*x_imag;
% We need to normalize the coefficients to get the desired auto correlation
output = y_real + sqrt(-1)*y_imag;
I_out = real(output(1:NumberSamples))/sqrt( mean( real(output(1:NumberSamples)).^2 ));
Q_out = imag(output(1:NumberSamples))/sqrt( mean( imag(output(1:NumberSamples)).^2 ));
% take magnitude squared of each component and add together
r = sqrt( (I_out).^2 + (Q_out).^2 );
phase = angle( (I_out) + sqrt(-1)*Q_out );
% normalize and compute rms level
rms = sqrt( mean( r.*r ) );
r = r(1:NumberSamples)/rms;
% This is the complex gaussian envelope
r_cmplx = r.*( cos( phase ) + sqrt(-1)*sin(phase) );
r_real=r.*( cos( phase ));
r_imag=r.*(sin(phase) );
% Find the autocorrelation
t=-(NumberSamples-1)*fdTs:fdTs:(NumberSamples-1)*fdTs;
autocorr=xcorr(r_real)/NumberSamples;
%Analytical/Desired autocorrelation
j0=0.5*besselj(0,t*2*pi);
%Difference between the analytical and generated autocorrelations.
diff=real(j0'-autocorr);
figure(1)
hist(r_real);
hold on;
title(' Histogram of real part of complex Gaussian fading process ');
hold off;
figure(2)
hist(r_imag);
title(' Histogram of imaginary part of complex Gaussian fading process ');
hold off;
figure(3);
plot(t,real(autocorr));
hold on;
plot(t,j0,'r');
title('Simulated and theoretical autocorrelation functions');
xlabel('time intervals');
ylabel('Rx');
legend(' Simulated','Theoretical');
hold off;
figure(4);
plot(diff,'k');
hold on;
title(' Difference between simulated and theoretical auto correlations');
hold off;
figure(5);
hist(r,50);
hold on;
title(' Histogram of the envelope of the complex Gaussian fading process');
hold off;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -