www.pudn.com > white_ttwo_doa.rar > white_ttwo_doa.m, change:2010-12-12,size:11036b


% LMS Smart Antenna Simulation 
% File name: LMS_6DOA_2Sig_White_Gain.m 
% This program simulates a Smart Antenna system receiving three white input multipath 
% signals from two sources (3 each) and distinguishing each multipath. 
u1 = sign(randn(1, 5000));                         % Inputs from 1st multipath, 1st signal 
u2 = [0, u1];                                      % Inputs from 2nd multipath, 1st signal 
u3 = u2;                                            % Inputs from 3rd multipath, 1st signal 
v1 = sign(randn(1, 5000));                         % Inputs from 1st multipath, 2nd signal 
v2 = [0, v1];                                       % Inputs from 2nd multipath, 2nd signal 
v3 = v2;                                            % Inputs from 3rd multipath, 2nd signal 
N = length(u1);                                     % Number of input signals 
n = 25;                                             % Number of antenna elements 
nn = (randn(N, n) + j * randn(N, n)) * 0.1;  % Noise inputs for SA 
mu = 0.008;                                         % Step-size 
fc = 4 * 10^8;                                      % Carrier frequency 
Tu1 = 100 * 10^(-6);                                  % Time for 1st signal to arrive at first element 
Tu2 = Tu1 + 1 / fc;                                 % Time for 1st signal to arrive at first element 
Tu3 = Tu2;                                          % Time for 1st signal to arrive at first element 
Tv1 = 150 * 10^(-6);                                  % Time for 1st signal to arrive at first element 
Tv2 = Tv1 + 1 / fc;                                 % Time for 1st signal to arrive at first element 
Tv3 = Tv2;                                          % Time for 1st signal to arrive at first element 
c = 3 * 10^8;                                      % Speed of light 
lambda = c / fc;                                    % Wavelength 
d = lambda / 2;                                    % Element spacing 
DOAu1 = 60;                                         % Direction of Arrival of u1 
DOAu2 = 30;                                         % Direction of Arrival of u2 
DOAu3 = -20;                                        % Direction of Arrival of u3 
DOA_radu1 = DOAu1 * pi / 180;                  % DOAu1 in radians 
DOA_radu2 = DOAu2 * pi / 180;                    % DOAu2 in radians 
DOA_radu3 = DOAu3 * pi / 180;                   % DOAu2 in radians 
sin_u1 = sin(DOA_radu1);                          % Sine of DOA_radu1 
sin_u2 = sin(DOA_radu2);                          % Sine of DOA_radu2 
sin_u3 = sin(DOA_radu3);                          % Sine of DOA_radu3 
DOAv1 = -50;                                        % Direction of Arrival of v1 
DOAv2 = 0;                                          % Direction of Arrival of v2 
DOAv3 = 45;                                         % Direction of Arrival of v3 
DOA_radv1 = DOAv1 * pi / 180;                    % DOAv1 in radians 
DOA_radv2 = DOAv2 * pi / 180;                   % DOAv2 in radians 
DOA_radv3 = DOAv3 * pi / 180;                    % DOAv2 in radians 
sin_v1 = sin(DOA_radv1);                          % Sine of DOA_radv1 
sin_v2 = sin(DOA_radv2);                          % Sine of DOA_radv2 
sin_v3 = sin(DOA_radv3);                          % Sine of DOA_radv3 
ru = zeros (3, n);                                 % Received 1st signal at each element 
yu = zeros (3, n);                                  % ru + noise 
xu = zeros (3, N);                                  % Estimate of 1st signal 
eu = zeros (3, N);                                % Error between u and x for each multipath of 
%%1st signal 
Bu = zeros (3, N);                                  % Squared error of multipath of 1st signal 
Fu = zeros (3, n);                                 % Initialise SA weight vectors to zero 
rv = zeros (3, n);                                  % Received 2nd signal at each element 
yv = zeros (3, n);                                  % rv + noise 
xv = zeros (3, N);                                  % Estimate of 2nd signal 
ev = zeros (3, N);                                % Error between v and x for each multipath of 
%%2nd signal 
Bv = zeros (3, N);                                  % Squared error of multipath of 2nd signal 
Fv = zeros (3, n);                                  % Initialise SA weight vectors to zero 
Gainu1 = 0.5 * (exp(j * pi / 2));                 % Gain experienced by u1 
Gainu2 = 0.66 * (exp(j * pi / 6));                % Gain experienced by u2 
Gainu3 = 0.75 * (exp(j * pi / 4));                % Gain experienced by u3 
Gainv1 = 0.6 * (exp(j * pi / 7));                 % Gain experienced by v1 
Gainv2 = 0.8 * (exp(j * pi / 5));                 % Gain experienced by v2 
Gainv3 = 0.7 * (exp(j * pi / 3));                 % Gain experienced by v3 
for k = 1: N 
U1 = Gainu1 * [u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k),..... 
u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k), u1(k),....... 
u1(k), u1(k), u1(k), u1(k), u1(k)]; 
U2 = Gainu2 * [u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k),.... 
u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k), u2(k),.... 
u2(k), u2(k), u2(k), u2(k), u2(k)]; 
U3 = Gainu3 * [u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k),..... 
u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k), u3(k),..... 
u3(k), u3(k), u3(k), u3(k), u3(k)]; 
V1 = Gainv1 * [v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k),..... 
v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k), v1(k),..... 
v1(k), v1(k), v1(k), v1(k), v1(k)]; 
V2 = Gainv2 * [v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k),..... 
v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k), v2(k),..... 
v2(k), v2(k), v2(k), v2(k), v2(k)]; 
V3 = Gainv3 * [v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k),..... 
v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k), v3(k),..... 
v3(k), v3(k), v3(k), v3(k), v3(k)]; 
for m = 1: n 
expu1A = exp(-j * 2 * pi * fc * Tu1); 
expu2A = exp(-j * 2 * pi * fc * Tu2); 
expu3A = exp(-j * 2 * pi * fc * Tu3); 
expu1B(m) = exp(-j * 2 * pi * (m-1) * d * sin_u1 / lambda); 
expu2B(m) = exp(-j * 2 * pi * (m-1) * d * sin_u2 / lambda); 
expu3B(m) = exp(-j * 2 * pi * (m-1) * d * sin_u3 / lambda); 
expv1A = exp(-j * 2 * pi * fc * Tv1); 
expv2A = exp(-j * 2 * pi * fc * Tv2); 
expv3A = exp(-j * 2 * pi * fc * Tv3); 
expv1B(m) = exp(-j * 2 * pi * (m-1) * d * sin_v1 / lambda); 
expv2B(m) = exp(-j * 2 * pi * (m-1) * d * sin_v2 / lambda); 
expv3B(m) = exp(-j * 2 * pi * (m-1) * d * sin_v3 / lambda); 
ru(1, m) = U1(m) * expu1A * expu1B(m) + U2(m) * expu2A * expu2B(m) +.... 
U3(m) * expu3A * expu3B(m) + V1(m) * expv1A * expv1B(m) +.... 
V2(m) * expv2A * expv2B(m) + V3(m) * expv3A * expv3B(m); 
yu(1, m) = ru(1, m) + nn(k, m); 
ru(2, m) = U2(m) * expu2A * expu2B(m) + U3(m) * expu3A * expu3B(m) +..... 
V1(m) * expv1A * expv1B(m) + V2(m) * expv2A * expv2B(m) +..... 
V3(m) * expv3A * expv3B(m) + U1(m) * expu1A * expu1B(m); 
yu(2, m) = ru(2, m) + nn(k, m); 
ru(3, m) = U3(m) * expu3A * expu3B(m) + V1(m) * expv1A * expv1B(m) +.... 
V2(m) * expv2A * expv2B(m) + V3(m) * expv3A * expv3B(m) +.... 
U1(m) * expu1A * expu1B(m) + U2(m) * expu2A * expu2B(m) ; 
yu(3, m) = ru(3, m) + nn(k, m); 
rv(1, m) = V1(m) * expv1A * expv1B(m) + V2(m) * expv2A * expv2B(m) +.... 
V3(m) * expv3A * expv3B(m) + U1(m) * expu1A * expu1B(m) +.... 
U2(m) * expu2A * expu2B(m) + U3(m) * expu3A * expu3B(m); 
yv(1, m) = rv(1, m) + nn(k, m); 
rv(2, m) = V2(m) * expv2A * expv2B(m) + V3(m) * expv3A * expv3B(m) +..... 
U1(m) * expu1A * expu1B(m) + U2(m) * expu2A * expu2B(m) +..... 
U3(m) * expu3A * expu3B(m) + V1(m) * expv1A * expv1B(m); 
yv(2, m) = rv(2, m) + nn(k, m); 
rv(3, m) = V3(m) * expv3A * expv3B(m) + U1(m) * expu1A * expu1B(m) +..... 
U2(m) * expu2A * expu2B(m) + U3(m) * expu3A * expu3B(m) +...... 
V1(m) * expv1A * expv1B(m) + V2(m) * expv2A * expv2B(m) ; 
yv(3, m) = rv(3, m) + nn(k, m); 
end; 
xu(1, k) = yu(1, :) * Fu(1, :)'; 
eu(1, k) = u1(k) - xu(1, k); 
Fu(1, :) = Fu(1, :) + mu * yu(1, :) * conj(eu(1, k)); 
Bu(1, k) = eu(1, k) * eu(1, k)'; 
xu(2, k) = yu(2, :) * Fu(2, :)'; 
eu(2, k) = u2(k) - xu(2, k); 
Fu(2, :) = Fu(2, :) + mu * yu(2, :) * conj(eu(2, k)); 
Bu(2, k) = eu(2, k) * eu(2, k)'; 
xu(3, k) = yu(3, :) * Fu(3, :)'; 
eu(3, k) = u3(k) - xu(3, k); 
Fu(3, :) = Fu(3, :) + mu * yu(3, :) * conj(eu(3, k)); 
Bu(3, k) = eu(3, k) * eu(3, k)'; 
xv(1, k) = yv(1, :) * Fv(1, :)'; 
ev(1, k) = v1(k) - xv(1, k); 
Fv(1, :) = Fv(1, :) + mu * yv(1, :) * conj(ev(1, k)); 
Bv(1, k) = ev(1, k) * ev(1, k)'; 
xv(2, k) = yv(2, :) * Fv(2, :)'; 
ev(2, k) = v2(k) - xv(2, k); 
Fv(2, :) = Fv(2, :) + mu * yv(2, :) * conj(ev(2, k)); 
Bv(2, k) = ev(2, k) * ev(2, k)'; 
xv(3, k) = yv(3, :) * Fv(3, :)'; 
ev(3, k) = v3(k) - xv(3, k); 
Fv(3, :) = Fv(3, :) + mu * yv(3, :) * conj(ev(3, k)); 
Bv(3, k) = ev(3, k) * ev(3, k)'; 
end; 
figure (1); clf; 
subplot(2, 1, 1); 
semilogy (abs(Bu(1, :)), 'b'); 
XLIM([0, 150]); 
YLIM([10^-7, 10^1]); 
hold on; 
semilogy (abs(Bu(2, :)), 'r'); 
XLIM([0, 150]); 
YLIM([10^-7, 10^1]); 
hold on; 
semilogy (abs(Bu(3, :)), 'g'); 
XLIM([0, 150]); 
YLIM([10^-7, 10^1]); 
hold off; 
grid on; zoom on; 
title ('Received Signal Error: 2 White Signals, 3 DOAs Each (1st Sig)'); 
xlabel ('Sample Interval'); 
ylabel ('[U - XU] ^2 Error'); 
legend ('DOA1, Sig1', 'DOA2, Sig1', 'DOA3, Sig1', 4); 
subplot(2, 1, 2); 
semilogy (abs(Bv(1, :)), 'm'); 
XLIM([0, 150]); 
YLIM([10^-7, 10^1]); 
hold on; 
semilogy (abs(Bv(2, :)), 'c'); 
XLIM([0, 150]); 
YLIM([10^-7, 10^1]); 
hold on; 
semilogy (abs(Bv(3, :)), 'k'); 
XLIM([0, 150]); 
YLIM([10^-7, 10^1]); 
hold off; 
grid on; zoom on; 
title ('Received Signal Error: 2 White Signals, 3 DOAs Each (2nd Sig)'); 
xlabel ('Sample Interval'); 
ylabel ('[V - XV] ^2 Error'); 
legend ('DOA1, Sig2', 'DOA2, Sig2', 'DOA3, Sig2', 4); 
angle_min = -90 * pi / 180; 
angle_max = 90 * pi / 180; 
angle_incr = 1 * pi / 180; 
q = 0; 
Fu(1, :) = conj(Fu(1, :)); 
Fu(2, :) = conj(Fu(2, :)); 
Fu(3, :) = conj(Fu(3, :)); 
Fv(1, :) = conj(Fv(1, :)); 
Fv(2, :) = conj(Fv(2, :)); 
Fv(3, :) = conj(Fv(3, :)); 
for angle1 = angle_min : angle_incr : angle_max 
q = q + 1; 
angle2(q) = 2 * pi * d * sin(angle1) / lambda; 
for t = 1: n 
G(t) = exp(j * angle2(q) * (t-1)); 
end; 
beamu1(q) = abs(Fu(1, :) * G'); 
beamu2(q) = abs(Fu(2, :) * G'); 
beamu3(q) = abs(Fu(3, :) * G'); 
beamv1(q) = abs(Fv(1, :) * G'); 
beamv2(q) = abs(Fv(2, :) * G'); 
beamv3(q) = abs(Fv(3, :) * G'); 
end; 
angle_range = angle_min : angle_incr : angle_max; 
figure (2); clf; 
polar (angle_range, beamu1, 'b'); 
hold on; 
polar (angle_range, beamu2, 'r'); 
hold on; 
polar (angle_range, beamu3, 'g'); 
hold on; 
polar (angle_range, beamv1, 'm'); 
hold on; 
polar (angle_range, beamv2, 'c'); 
hold on; 
polar (angle_range, beamv3, 'k'); 
hold off; 
view(90, -90); 
legend ('DOA1, Sig1', 'DOA2, Sig1', 'DOA3, Sig1', 'DOA1, Sig2', 'DOA2, Sig2', 'DOA3, Sig2',4); 
zoom on;