-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmimosatchwithrls.m
More file actions
136 lines (111 loc) · 2.91 KB
/
mimosatchwithrls.m
File metadata and controls
136 lines (111 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
clc
clear all
close all
%%%%%%%%%%%%in the name of ALLAH%%%%%%%%%
%%%%%%%%%%%%initial values%%%%%%%%%
L = 1200;
ts = 1/10;
fd = 0;
M = 4;
m = log2(M);
SNR_range = 0:1:30;
k = 3;
nRx = 2;
nTx = 2;
L_chan = 1;
p01 = .028;
p10 = .02;
% u = 0.0001;
lplant = 2;
delta = 0.1;
lambda = 1;
numSNR = length(SNR_range);
env_factor = 20;
%%%%%%%%%
data = randi([0,M-1] ,1 ,L);
x = reshape(data ,[nTx ,L/nTx]);
xmod = pskmod(x ,M);
desired = xmod;
berVec = zeros(1 ,numSNR);
for i = 1:nRx
for j = 1:nTx
hchan1 (i, j) = rayleighchan(ts ,fd);
hchan1 (i, j).storePathGains = 1;
hchan1 (i, j).ResetBeforeFiltering = 0;
hchan2 (i, j) = ricianchan(ts ,fd ,k);
hchan2 (i, j).storePathGains = 1;
hchan2 (i, j).ResetBeforeFiltering = 0;
end;
end;
for SNR_i = 1 :numSNR
W0 = randn (nRx ,nTx);
W1 = randn (nRx ,nTx);
yW = zeros(nRx ,L/nTx);
%%%%%%%%%%%%%
a = 0;
for l = 1:(L/nTx)
true_state_sequence (l) = a;
if (a == 0)
for i = 1:nRx
y (i, l) = 0;
for j = 1:nTx
y (i, l) = y (i, l) + filter (hchan1 (i, j), xmod (j,l));
end;
end;
r = rand;
if (r < p01)
a = 1;
end;
else
for i = 1:nRx
y (i, l) = 0;
for j = 1:nTx
y (i, l) = y (i, l) + filter (hchan2 (i, j), xmod(j,l));
end;
end;
r = rand;
if (r < p10)
a = 0;
end;
end;
end;
ynoisy = awgn (y ,SNR_range(SNR_i));
ch_state_sequence = chanel_state_sequence (ynoisy, env_factor);
% figure;
% hold on;
% plot (true_state_sequence, 'b');
% plot (ch_state_sequence, 'r');
%%%equalizer%%%
psy_inv0 = diag((ones(nRx ,1)/delta));
psy_inv1 = diag((ones(nRx ,1)/delta));
for kk = 1:(L/nRx)
if (1-true_state_sequence (kk))
u0 = psy_inv0 * ynoisy(: ,kk);
k0 = u0/(lambda + ynoisy(: ,kk)'*u0);
yW(1:nRx, kk)= W0' * ynoisy(:, kk);
e(:, kk) = desired(1:nRx, kk) - yW(1:nRx, kk);
W0 = W0 + k0 * e(: ,kk)';
psy_inv0 = (psy_inv0 - (k0 *ynoisy(: ,kk)' *psy_inv0));
else
u1 = psy_inv1 * ynoisy(: ,kk);
k1 = u1/(lambda + ynoisy(: ,kk)'*u1);
yW(1:nRx, kk)= W1' * ynoisy(:, kk);
e(:, kk) = desired(1:nRx, kk) - yW(1:nRx, kk);
W1 = W1 + k1 * e(: ,kk)';
psy_inv1 = (psy_inv1 - (k1 *ynoisy(: ,kk)' *psy_inv1));
end
end
% figure
% plot (sum (abs (e)));
ydemod = pskdemod(yW ,M);
berVec(SNR_i) = sum (sum (xor(x ,ydemod )));
end
BER_sim = berVec / L;
% Compute theoretical performance results, for comparison
BERtheory = berfading(SNR_range,'psk',M,1);
% Plot BER results
semilogy(SNR_range,BERtheory,'b-',SNR_range,BER_sim,'r-');
grid on
legend('Theoretical BER','Empirical BER');
xlabel('SNR (dB)'); ylabel('BER');
title(['MIMO Sattelite Channel (fd = ' num2str(fd) ') ']);