relationship between snr and eb_n0.txt

来自「是matlab的源代码」· 文本 代码 · 共 117 行

TXT
117
字号
%what in world is the relationship between SNR and Eb/N0

%Eb/N0=1/(2*r*(sigma)^2)

clc
clear all
%close all

givenSNR=[1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10]         %dB
r=1;
k=5000000;

Eb_N0=10.^(givenSNR./10);
sigma=(1./(2*r.*Eb_N0).^0.5)


source=1-2*randint(1,k,[0,1]);

for noise_i=1:length(givenSNR)
    noise=sigma(noise_i)*randn(1,k);

    receive=source+noise;

    error_num=0;
    for i=1:k
        if receive(i)>0&&source(i)==-1||receive(i)<0&&source(i)==1
          error_num=error_num+1;
        end
    end
    error_rate(noise_i)=error_num/k;
end


hold on
grid minor

semilogy(givenSNR,error_rate,'g')
        




























%what in world is the relationship between SNR and Eb/N0

%Eb/N0=1/(2*r*(sigma)^2)

clc
clear all
%close all

givenSNR=[1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10]         %dB
r=1;
k=5000000;

Eb_N0=10.^(givenSNR./10);
sigma=(1./(2*r.*Eb_N0).^0.5)


source=1-2*randint(1,k,[0,1]);

for noise_i=1:length(givenSNR)
    noise=sigma(noise_i)*randn(1,k);

    receive=source+noise;

    error_num=0;
    for i=1:k
        if receive(i)>0&&source(i)==-1||receive(i)<0&&source(i)==1
          error_num=error_num+1;
        end
    end
    error_rate(noise_i)=error_num/k;
end


hold on
grid minor

semilogy(givenSNR,error_rate,'g')
        












⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?