1

我环顾四周,但找不到在 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 完成此任务的线索。

将感谢任何解决此问题的实现的链接

4

1 回答 1

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)
于 2013-04-04T09:54:19.400 回答