什么是信噪比SNR?
SNR的定义在 胡广书《数字信号处理理论、算法与实现(第三版)》(清华大学出版社)第20页有写。
CSDN上一篇blog也进行了详细讲述:
https://blog.csdn.net/u012995500/article/details/87606346
具体说来包含几个要点:
(1)白噪声的功率用其方差来定义
(2)离散信号的功率可以使用公式:
(3) 信噪比SNR计算公式为:
2. MATLAB代码如下:
function y = add_gaussian_noise_snr_db(signal, snr)x = signal(:)';power_of_signal = (x*x')/length(x);power_of_noise = power_of_signal/(10^(snr/10)); % the std of the noise is the power of the noisenoise0 = randn(size(x));noise1 = (noise0 - mean(noise0))/std(noise0 - mean(noise0));y = sqrt(power_of_noise)*noise1+ x;end