📄 codeg1.m
字号:
function [err]=codeG1(index,snr,nsymb,Mary,modtype,nRx,err);
%Routine that preforms simulations based on PSK Mary modulation
%and using coding scheme G1 (note this means no coding)
nTx=1;
%Generate Data
%Possible Symbol Set
Set=[0:Mary-1]';
Smap=dmodce(Set,1,1,modtype,Mary);
%Generate Symbols
symb=randsrc(nsymb,1,[0:Mary-1]);
%Encode
msg=dmodce(symb,1,1,modtype,Mary);
%Noise Stats
Eav=Smap'*Smap/Mary;
NF=10^(snr/10);
S=sqrt(nTx*Eav/(2*NF));
%Simulate Channel
noise=S*(randn(nsymb,nRx) + i*randn(nsymb,nRx));
H=(randn(nsymb,nRx) + i*randn(nsymb,nRx))/sqrt(2); %Channel Gain Matrix
for j=1:nRx,
rx(:,j) = H(:,j).*msg + noise(:,j);
end
%Preform maximum liklihood demodulation
for k=1:nsymb
h=H(k,:); r=rx(k,:);
for L=1:Mary
C = 0;
for j=1:nRx,
C = C + (r(j) - h(j)*Smap(L))' * (r(j) - h(j)*Smap(L));
end
est_s1(L) = C;
end
%Decide in favour of min value
[A,B]=min(est_s1);
shat(k)=B-1; %-1 b/c index starts at 0 and not 1
end
%Compute symbol errors
err(index)=sum(shat~=symb');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -