方式一
分别对信号实部和虚部加噪,SNR=30,然后将实部和虚部合起来变成复信号,计算合起来之后的信号与噪声功率之比
%% 测试加噪方式
clear;close all;clc;
M=4;len=10000;
xk = randi([0,M-1],1,len);
xk = pskmod(xk,4);
SNR = 30;
xkR = real(xk); xkI=imag(xk);
%% 方式1
% ykR=awgn(xkR,SNR,'measured'); % 具体实现
sigPowerR=sum(abs(xkR(:)).^2)/numel(xkR);
reqSNR= 10^(SNR/10);
noisePowerR = sigPowerR/reqSNR;
noiseR = sqrt(noisePowerR)* randn(size(xkR));
ykR = xkR+noiseR;% ykI=awgn(xkI,SNR,'measured');
sigPowerI=sum(abs(xkI(:)).^2)/numel(xkI);
noisePowerI = sigPowerI/reqSNR;
noiseI = sqrt(noisePowerI)* randn(size(xkI));
ykI = xkI+noiseI;yk1=ykR+1j*ykI;sig1=xkR+1j*xkI; noise1 = noiseR+1j*noiseI;
sigPower1 = mean(abs(sig1).^2);
noisePower1 = mean(abs(noise1).^2);
rate1 = sigPower1/noisePower1;
方式二
直接对复信号加噪,SNR=30,计算信号与噪声功率之比
%% 方式2
% xkC=awgn(xk,SNR,'measured');
sigPower21 = sum(abs(xk(:)).^2)/numel(xk);
noisePower21 = sigPower21/reqSNR;
noise2 = sqrt(noisePower21/2)* (randn(size(xk)) + 1i*randn(size(xk)));
yk2=xk+noise2;sig2 = xk;
sigPower22 = mean(abs(sig2).^2);
noisePower22 = mean(abs(noise2).^2);
rate2 = sigPower22/noisePower22;
结论
两种方式所得的复信号信噪比相同