📄 alamouti.m
字号:
% Simulation of STC codec
% employing the Alamouti scheme
% with N = 2 transmit antennas
% and M = 1 receive antenna.
% Modulation format: QPSK
% Symbol Frame length: "NS" complex samples
% Standard deviation of AWGN: "sig"
% Complex channel coefficients: "h1", "h2" fixed.
%
% Symbol errors are counted and
% output as symbol error rate.
% =============================
% Ideal constellation points
d1 = 0.5*sqrt(2)*(-1-j);
d2 = 0.5*sqrt(2)*(1-j);
d3 = 0.5*sqrt(2)*(1+j);
d4 = 0.5*sqrt(2)*(-1+j);
%Number of symbols in data set
NS = 10000;
%Set of possible symbols
XP = [d1 d2 d3 d4];
% Error counter
errcount = 0;
%Noise variance
sig = 0.08;
for k = 1:NS
n1 = gnoise(sig, 1)+j*gnoise(sig,1);
n2 = gnoise(sig, 1)+j*gnoise(sig,1);
m1 = floor(rand(1)*3.999)+1;
x1 = XP(m1);
m2 = floor(rand(1)*3.999)+1;
x2 = XP(m2);
% Complex channel coefficients
h1 = 0.0707 + j*0.0707;
h2 = 0.1500 + j*0.2598;
% Complex AWGN samples
%n1 = 0.0100 + j*0.0020;
%n2 = -0.0030 + j*0.0030;
alpha = abs(h1)^2 + abs(h2)^2;
% Received signals
y1 = h1*x1 + h2*x2 + n1;
y2 = -h1*conj(x2) + h2*conj(x1) + n2;
% Statistics
x1t = conj(h1)*y1 + h2*conj(y2);
x2t = conj(h2)*y1 - h1*conj(y2);
for p = 1:4
G1(p) = abs(x1t - alpha*XP(p))^2;
G2(p) = abs(x2t - alpha*XP(p))^2;
end
[dummy, p1] = min(G1);
[dummy, p2] = min(G2);
first_sample = XP(m1);
x1h = XP(p1);
second_sample = XP(m2);
x2h = XP(p2);
if abs(x1h - first_sample)> 0.001
errcount = errcount + 1;
end
if abs(x2h - second_sample)> 0.001
errcount = errcount + 1;
end
end
Number_of_Symbols = NS
Noise_Variance = sig
Number_of_Symbol_Errors = errcount
Symbol_Error_Rate = errcount/NS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -