How to generate Gaussian white noise with certain variance in Matlab?

315 ビュー (過去 30 日間)
Konstantinos
Konstantinos 2013 年 12 月 7 日
Hey, I have a signal Xmodt to which I want to add Gaussian white noise W with mean value equal to zero (by definition) and variance equal to 1/(Ts*(10^(SNRdb/10))). From what I have found online, I created the following code:
Ts=0.1; %Given sampling period
SNRdb = 10; %Given SNRdb
variance = 1/(Ts*(10^(SNRdb/10)));
W = sqrt(variance).*randn(1,size(Xmodt,2)); %Gaussian white noise W
Xmodt = Xmodt + W; %Add the noise
I know that in this example variance equals to 1, but I need to find a general solution. So, is this code correct? Thanks in advance!

採用された回答

Walter Roberson
Walter Roberson 2013 年 12 月 7 日
Skip the first 2 lines, assign the desired value to the variance, and continue on with W and Xmodt.
  1 件のコメント
Konstantinos
Konstantinos 2013 年 12 月 8 日
編集済み: Konstantinos 2013 年 12 月 8 日
Well, the first 3 lines are not my problem but I added them for typical reasons. So, you mean that the last 2 lines of code are correct? Do they produce and add white Gaussian noise to the signal?

サインインしてコメントする。

その他の回答 (3 件)

Zerihun Abebe
Zerihun Abebe 2016 年 4 月 26 日
Computer Experiment. Consider the linear system defined by Generate 1500 samples of a unit-variance, zero-mean, white-noise sequence xn, n = 0, 1, . . . , 1499 and filter them through the filter H to obtain the output sequence yn. Compute the sample cross-correlation ˆRyx(k) for k = 0, 1, . . . , 50 to obtain estimates of the impulse response hk. On the same graph, plot the estimated impulse response versus time, together with the simulated response Repeat, using a different realization of xn.

fluid
fluid 2017 年 10 月 22 日
編集済み: fluid 2017 年 10 月 22 日
y1 = wgn(1000, 1, 0); % a 1000-element white noise with power 0dBW, that is 1W
var(y1)
ans:
ans = 0.9979

Juan José Retana Díaz
Juan José Retana Díaz 2022 年 10 月 27 日
I have a doubt, what does the number "2" means in the line: W = sqrt(variance).*randn(1,size(Xmodt,2));
Please help me, I need to add white gaussian noise to a signal with zero mean and a variance of 4.7 x 10^-5.
  1 件のコメント
Juan José Retana Díaz
Juan José Retana Díaz 2022 年 10 月 27 日
I forgot to say that my signal is real and only have 1x6000 double values

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFilter Analysis についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by