add white gaussian noise
10 ビュー (過去 30 日間)
古いコメントを表示
I tried to add noise to a signal. The signal noise ratio must be 0 dB. I tried with
signal_noise=awgn(signal,0,'measured')
Is there any method?
0 件のコメント
回答 (2 件)
Meg Noah
2025 年 8 月 7 日 17:14
編集済み: Meg Noah
2025 年 8 月 7 日 17:14
% signal is a sine wave of 2 Hz
nSamples = 1000;
f = 2; % [Hz]
time = linspace(0, 2, nSamples+1);
signal = sin(2*pi*f*time);
signal_noise=awgn(signal,0,'measured');
% calculate the signal power
signalPower = sum((signal).^2)./nSamples;
% the gaussian white noise
noiseValues = signal_noise - signal;
% verify the Signal-to-Noise value
noisePower = sum(noiseValues.^2)/numel(noiseValues);
SNR = 10*log10(signalPower/noisePower);
fprintf(1,"standard deviation of noise = %f\n", std(noiseValues));
fprintf(1,"SNR: %f\n", SNR);
% Method WITHOUT the awgn
% SNR in db is 10log(Psignal/Pnoise)
snrDb = 0; % [dB]
% noise power such that signal power is 10 dB more
% 10 = 10 log (Ps / Pn)
% Pn is variance which for zero mean gaussian noise
% is essentially - square sum of all samples -> divided by numSamples
noiseStd = sqrt(signalPower / 10^(snrDb/10));
noiseMean = 0;
% generate the gaussian white noise
noiseValues = noiseStd*randn(nSamples,1) + noiseMean;
% verify the Signal-to-Noise value
noisePower = sum(noiseValues.^2)/numel(noiseValues);
SNR = 10*log10(signalPower/noisePower);
fprintf(1,"noiseStd: model input: %f simulation output: %f\n", noiseStd, std(noiseValues));
fprintf(1,"SNR: %f\n", SNR);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Propagation and Channel Models についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!