📄 vblast_decode.m
字号:
function [err] = vblast_decode(snr,Smap)
%Routine to perform optimal order decoding for vblast
global nTx nRx modtype Mary
if nargin == 0,
clc; clear;
snr = 12;
nTx = 2;
nRx = 2;
modtype = 'psk'; %'psk' or 'qask'
Mary = 8; %Constellation size (how many symbols in the set)
end
%Generate Data
%Possible Symbol Set
%Set=[0:Mary-1]';
%Smap=dmodce(Set,1,1,modtype,Mary);
%[symb,Smap]=psk_gen(Mary);
%Generate Symbols
%symb=randsrc(nTx,1,[0:Mary-1]);
symb=ceil(rand(nTx,1)*Mary);
%Encode with PSK
%Tx=dmodce(symb,1,1,modtype,Mary);
[Tx]=psk_gen(Mary,symb);
%Generate channel
H=(randn(nRx,nTx) + i*randn(nRx,nTx))/sqrt(2); %FOR RAYLEIGH TESTING !!!
%Noise Stats
Eav=Smap'*Smap/Mary;
NF=10^(snr/10);
NP=sqrt(nTx*Eav/(2*NF)); %signal power / snr = noise power
noise=NP*(randn(nRx,1) + i*randn(nRx,1)); %Get noise
%Generate received signal
Rx=H*Tx + noise;
%Decode using V-Blast algorithm
%Initialization
yhat = zeros(size(Tx));
G = pinv(H); %G*H = eye(nRx), remember nRx >= nTx
for j = 1:nTx,
k(j) = norm(G(:,j));
end
[value,index]=sort(k);
%Recursion
for i = 1:nTx,
G = pinv(H);
pos=index(i); %row with smallest norm first, end with largest norm
w = G(pos,:);
y = w*Rx;
%Slice to get best guess transmitted signal
dst = zeros(Mary,1);
for p = 1:Mary
dst(p) = norm(y - Smap(p));
end
[u,v] = sort(dst);
yhat(pos) = Smap(v(1)); %This is always 'v(1)', we want minimum
%Subtract off contribution
Rx = Rx - yhat(pos)*H(:,pos);
%Zero that column of H
H(:,pos) = zeros(nRx,1);
end
%[Tx yhat]
err = sum(Tx~=yhat);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -