⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cm_bpske.m

📁 BPSK在AWGN信道下的仿真程序
💻 M
字号:
function[p]=cm_bpske(snr_in_db)
% [p]=cm_bpske(snr_in_db)
% cm_bpske finds the probability of error for the given value of snr_in_db

N=5000;
E=1;                            %energy per symbol
snr=10^(snr_in_db/10);         %signal to noise ratio
sgma=E/sqrt(snr*2);           %noise variance

%generation of data source
for i=1:N
    temp=rand;
    if(temp<0.5)
        dsource(i)=0;
    else
        dsource(i)=1;
    end
end


%detection and the probability of errror calculation
numofbiterror=0;
for i=1:N
    %received signal at the detector ,for the ith symbol is:
       if (dsource(i)==0)
        r0=E+gngauss(sgma);
        r1=gngauss(sgma);
    else
        r1=E+gngauss(sgma);
        r0=gngauss(sgma);
    end
    
    
    % the detector is:
    if(r0>r1)
        decis=0;
    else
        decis=1;
    end
        
    %increment the error counter,if the decision is not correct
    if (decis~=dsource(i))
        numofbiterror=numofbiterror+1;
    end
    
end
p=numofbiterror/N;

    

⌨️ 快捷键说明

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