awgn.m
来自「一些关于调指和解调的小程序」· M 代码 · 共 28 行
M
28 行
function [out1,out2]=AWGN(input,Eb_N0,Ps,k,R,P)
%*******************************************************************************************
%%% Note that SNR=(Eb/N0*R*k)/P, the Ps and Pn should calculated according to SNR, not Eb/N0
%%% This function generate and add the AWGN noise to the tansmetted signals
%%% input and out are all "serial" sequence
%%% Eb_N0 : ratio of bit energy to noise power spectral density
%%% input : input signal sequence(complex numbers)
%%% Ps : average power of the signal
%%% rb : i.e. Eb/N0, raito of information bit energe to AWGN noise power spectral density
%%% k : the number of bits of each symbol
%%% R : coding rate
%%% P : spreading factor, i.e. "SF"
%*******************************************************************************************
L=length(input);
ebn=10^(Eb_N0/10);
SNR=(ebn.*R.*k)./P;
pow_s=Ps;
pow_n=pow_s/SNR; %%% noise average power(devided to real and imaginary parts,so devided by 2)
delta=sqrt(pow_n/2);
x=randn(1,L)*delta;
y=randn(1,L)*delta;
noise=x+j*y;
out1=noise+input;
out2=pow_n;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?