Matlab中二进制非对称通道的AWGN仿真

时间:2013-04-04 02:51:50

标签: matlab

我看了很多,但无法在matlab中获得模拟二进制非对称通道的解决方案。我应该模拟BSC(二进制对称信道)以及错误概率为0.001的非对称信道。

我设法做了二进制对称模拟(对于任何想要使用它的人)

r = rand(1000000,1);    % uniform data set generation
x = zeros(1000000,1);   % data to be sent initialised 

for i = 1:1000000       % mapped to BPSK signal (-1,1)
if r(i,1) >= 0.5
    x(i,1) = 1;
else
    x(i,1) = -1;
end
end

SNR = qfuncinv(0.001);
SNRdB = 10*log(SNR);
y = awgn(x,SNRdB);    
y = awgn(x,9.79982258);    %noise added to inputs through Signal to noise 
               %ratio


for i = 1:1000000
if(abs(y(i,1) - 1) < abs(y(i,1) + 1) )    %between -1 and 1
    y(i,1) = 1;                         %map back through 
else            %minimum distance estimations
    y(i,1) = -1;
end

if(x(i,1) == y(i,1))    % determine if estimation errors are made
    r(i,1) = 0; 
else
    r(i,1) = 1;
end
end

errors = sum(r);
sprintf('%0.8f',errors/1000000)     %show error percentage

那么,我仍然需要进行非对称通道模拟,但是找不到使用matlab实现这一目标的领先优势。

将欣赏解决此问题的实现的任何链接

1 个答案:

答案 0 :(得分:1)

如果我错了,请纠正我,但非对称二进制通道是一个二进制通道,从0到1的概率误差从1到0不等。那么,你的代码看起来应该是这样的:

function channel_simulation(BER1,BER2,Nbits)

    % BER1: prob 0->1
    % BER2: prob 1->0

    if nargin <3, Nbits = 10^6; end

    % Data generation mapped to BPSK signal (-1,1)
    r = rand(Nbits,1);   
    x = 2*(r>=0.5)-1;

    % Noise (channel 1)
    SNRdB1 = 10*log(qfuncinv(BER1));
    y1 = awgn(x,SNRdB1);    
    y1 = 2*(abs(y1-1)<abs(y1+1))-1;
    r1=(x~=y1);

    % Noise (channel 2)
    SNRdB2 = 10*log(qfuncinv(BER2));
    y2 = awgn(x,SNRdB2);    
    y2 = 2*(abs(y2-1)<abs(y2+1))-1;
    r2=(x~=y2);

    % Error percentage
    errors = sum(r1.*(x<0)+r2.*(x>0));
    fprintf('Prob: %0.8f\n',errors/Nbits)    

end

你可以尝试称呼它:

channel_simulation(0.001,0.01)