shakeel006
Junior Member level 3
almouti code
Dear Sir
I downloaded Alamouti code from matlab central.I am unable to understand the following decoding part please explain.I have typed Q in comments for my question
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Decoding %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dh = sqrt(2)*[1 -1]/2; %Q: why this is used where it comes from?
%Computing the distances for the first symbol%
d11=((dh(1)-real(S(1)))^2+(imag(S(1)))^2); this is not distance formula between two points
d12=((dh(2)-real(S(1)))^2+(imag(S(1)))^2);
D1=[d11 d12]; %Distances for the received symbol
%Building the decisions vector for the first symbol%
for k=1:2
X1_dec(k)=((abs(dh(k)))^2)*sum(sum((abs(H)).^2)-1)+D1(k);
end
%Computing the distances for the second symbol%
d21=((dh(1)-real(S(2)))^2+(imag(S(2)))^2);
d22=((dh(2)-real(S(2)))^2+(imag(S(2)))^2);
D2=[d21 d22];
%Building the decisions vector for the second symbol%
for x=1:2
X2_dec(x)=((abs(dh(k)))^2)*sum(sum((abs(H)).^2)-1)+D2(x);
end
%The decisions!! We chose the little one%
[scelta1, posizione1]=min(X1_dec);
[scelta2, posizione2]=min(X2_dec);
If I can write in simple words what is ML detector it is as follows
arg min ( received signal - reference symbols ) ^2
where minimization is over all reference symbols.
I saw another example for BPSK which implemented ML decoding as follows.highlighted with bigger font
clear %clear matlab workspace
clc %clear command window
tic %intialize start time of simulation
M=2; % for BPSK we need only two symbols 0 or 1.
snr_db=0:12; % Range of 0-12 Dbs over which Pe will be calculated in this simulation
% LEN=[1e+6*ones(1,5) 1e+6*ones(1,5) 1e+6*ones(1,3)]; % number of bits transmitted i.e 10^6=100,0000.
LEN=[1e+6*ones(1,13)]; % number of bits transmitted i.e 10^6=100,0000.
srf=exp(j*2*pi*[0;1]/2); % reference signal
for k=1:length(snr_db)
bit_err=0;
for kk=1:LEN(k)
snr=10^(snr_db(k)/10); %SNR in real values
varn=1/(2*snr); %noise variance
data=randint(1,1,[0 M-1]); %random data generated
s=exp(2*j*pi*data/M); %signal tobe transmitted
n=sqrt(varn)*(randn(1,1)+j*randn(1,1)); %Complex gaussian distributed random data ???????
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Another way of ML decoding in different way
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=s+n; % signal tobe transmitted
f=(abs(x*ones(2,1)-srf)).^2; % abs(( received signal - reference symbols )) ^2
[fmn,argd]=min(f); % for complex f=min(abs(f)),so [number index]=min(f)
dr=argd-1; %get the index
bit_err=bit_err+(dr~=data);%if the received is not equal to data then increment error count
end
poe_n(k)=bit_err/LEN(k); %no of errors/100,0000
poe_n_exact(k)=qfunc(1/sqrt(varn));
Please explain the difference between the two ML decoding implementations .
best regards
Shakeel
Dear Sir
I downloaded Alamouti code from matlab central.I am unable to understand the following decoding part please explain.I have typed Q in comments for my question
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Decoding %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
dh = sqrt(2)*[1 -1]/2; %Q: why this is used where it comes from?
%Computing the distances for the first symbol%
d11=((dh(1)-real(S(1)))^2+(imag(S(1)))^2); this is not distance formula between two points
d12=((dh(2)-real(S(1)))^2+(imag(S(1)))^2);
D1=[d11 d12]; %Distances for the received symbol
%Building the decisions vector for the first symbol%
for k=1:2
X1_dec(k)=((abs(dh(k)))^2)*sum(sum((abs(H)).^2)-1)+D1(k);
end
%Computing the distances for the second symbol%
d21=((dh(1)-real(S(2)))^2+(imag(S(2)))^2);
d22=((dh(2)-real(S(2)))^2+(imag(S(2)))^2);
D2=[d21 d22];
%Building the decisions vector for the second symbol%
for x=1:2
X2_dec(x)=((abs(dh(k)))^2)*sum(sum((abs(H)).^2)-1)+D2(x);
end
%The decisions!! We chose the little one%
[scelta1, posizione1]=min(X1_dec);
[scelta2, posizione2]=min(X2_dec);
If I can write in simple words what is ML detector it is as follows
arg min ( received signal - reference symbols ) ^2
where minimization is over all reference symbols.
I saw another example for BPSK which implemented ML decoding as follows.highlighted with bigger font
clear %clear matlab workspace
clc %clear command window
tic %intialize start time of simulation
M=2; % for BPSK we need only two symbols 0 or 1.
snr_db=0:12; % Range of 0-12 Dbs over which Pe will be calculated in this simulation
% LEN=[1e+6*ones(1,5) 1e+6*ones(1,5) 1e+6*ones(1,3)]; % number of bits transmitted i.e 10^6=100,0000.
LEN=[1e+6*ones(1,13)]; % number of bits transmitted i.e 10^6=100,0000.
srf=exp(j*2*pi*[0;1]/2); % reference signal
for k=1:length(snr_db)
bit_err=0;
for kk=1:LEN(k)
snr=10^(snr_db(k)/10); %SNR in real values
varn=1/(2*snr); %noise variance
data=randint(1,1,[0 M-1]); %random data generated
s=exp(2*j*pi*data/M); %signal tobe transmitted
n=sqrt(varn)*(randn(1,1)+j*randn(1,1)); %Complex gaussian distributed random data ???????
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Another way of ML decoding in different way
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
x=s+n; % signal tobe transmitted
f=(abs(x*ones(2,1)-srf)).^2; % abs(( received signal - reference symbols )) ^2
[fmn,argd]=min(f); % for complex f=min(abs(f)),so [number index]=min(f)
dr=argd-1; %get the index
bit_err=bit_err+(dr~=data);%if the received is not equal to data then increment error count
end
poe_n(k)=bit_err/LEN(k); %no of errors/100,0000
poe_n_exact(k)=qfunc(1/sqrt(varn));
Please explain the difference between the two ML decoding implementations .
best regards
Shakeel