简体   繁体   English

如何将高斯白噪声添加到信号中

[英]How to add white Gaussian noise to signal

How can i add white Gaussian noise to signal. 如何将高斯白噪声添加到信号中。
Now, i'm using awgn function but it doesn't work. 现在,我正在使用awgn函数,但是它不起作用。
Am i give an incorrect parameter? 我输入的参数不正确吗?

EDITED 已编辑

x = -2:.002:2;

% Initail variables
M = 0;
V = 500*10^(-6);

% Creating a singal
T = -pi + (pi+pi)*rand(1,1);
S = (13.5)*cos(2*pi*x+T);

% Creating Noise singal
W = M+sqrt(V)*rand(1,2500);

% Adding Noise to signal // This doesn't work
SW = awgn(S,W,'measured');
% or this doesn't work too
SW = S + W;

Thanks in advance. 提前致谢。

在此处输入图片说明在此处输入图片说明

From Matlab manual 从Matlab手册

y = awgn(x,snr) adds white Gaussian noise to the vector signal x. y = awgn(x,snr)将白高斯噪声添加到矢量信号x。 The scalar snr specifies the signal-to-noise ratio per sample, in dB. 标量 snr指定每个样本的信噪比,以dB为单位。

Your vectors don't have the same size. 您的向量大小不一样。 S is 1x2001 and W is 1x2500. S是1x2001, W是1x2500。 Try 尝试

W = M + sqrt(V)*rand(size(S));

Then you can just add the signals by 然后您可以通过以下方式添加信号

SW = S + W;

As Kostya already wrote, awgn can be used if you know the desired SNR. 正如Kostya所写,如果您知道所需的SNR,则可以使用awgn

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM