How to Add random noise to a signal

조회 수: 1,339 (최근 30일)
lady bird
lady bird 2015년 5월 20일
편집: DGM 2023년 3월 4일
hello all
please can ou help me out adding a noise signal to my system.
i tried adding a sinus function , but i would like to add a random noise signal rather than the sinus function. I'm running simulation from 1 to 3000
if k>1000 & k<2000
dk(k)=sin(12*k*pi*ts);
x=A*x+B*u(k)+B*dk(k);
else
dk(k)=0;
x=A*x+B*u(k);
end
Thank you so much
Best regards
  댓글 수: 2
chris matthew
chris matthew 2020년 3월 14일
이동: DGM 2023년 3월 4일
how to add noise to audio not for signal
Image Analyst
Image Analyst 2020년 3월 14일
이동: DGM 2023년 3월 4일
What does that mean? Audio IS a signal. You can't add noise to audio without adding it to the signal that defines the audio waveform.

댓글을 달려면 로그인하십시오.

답변 (6개)

Thorsten
Thorsten 2015년 5월 20일
x = linspace(-2*pi, 2*pi);
plot(sin(x) + 0.5*rand(size(x)))
  댓글 수: 5
Image Analyst
Image Analyst 2020년 2월 12일
Tuhin, you can have the amplitude vary with the signal amplitude if you want. For example
% Create noise-only signal.
noisy_signal = rand(size(noise_free_signal));
% Create an amplitude for that noise that is 10% of the noise-free signal at every element.
amplitude = 0.1 * noise_free_signal;
% Now add the noise-only signal to your original noise-free signal to create a noisy signal.
% Be sure to use .*, not *, so that you do element-by-element multiplication.
noisy_signal = noise_free_signal + amplitude .* rand(size(noise_free_signal));
% Adjust amplitude to control the amount of noise.
Now the noise - the max possible noise amplitude - will vary according to the noise-free signal amplitude. Of course since it's noise, the noise won't always be the max possible, it will be less, but it could potentially get that high.
Tuhin Choudhury
Tuhin Choudhury 2020년 3월 16일
편집: Tuhin Choudhury 2020년 3월 16일
Hi,
Thanks. This would be more of a flexible scaling of the noise w.r.t the input signal.
BR- Tuhin

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2015년 5월 20일
So just use rand() instead of sin().
  댓글 수: 4
Prajakta Yeola
Prajakta Yeola 2017년 10월 29일
Can we use the same code if audio signal is .wav file? i.e. if x is a .wav file
Image Analyst
Image Analyst 2017년 10월 29일
Sure, just figure out the amplitude and add it
yNoisy = yOriginal + amplitude * rand(1, length(yOriginal));

댓글을 달려면 로그인하십시오.


KL
KL 2015년 5월 20일
Did you check the gaussian noise function?
  댓글 수: 2
lady bird
lady bird 2015년 5월 20일
i found a awgn function but i dont know how to use it in my case?
KL
KL 2015년 5월 20일
There's a difference between wgn() and awgn(). With the latter, you add noise throughout the whole range. I understand you want to add noise between certain time intervals. So in this case, I would suggest to use wgn(). At the moment I do not have the toolbox to use this function. Anyhow you shall use this function to calculate the noiseSignal variable according to @Image Analyst's code.

댓글을 달려면 로그인하십시오.


Aparna Gupta
Aparna Gupta 2017년 6월 21일
Can anyone please help me with the code to add awgn noise to an eeg signal,which i have taken from a database and the file is of .mat type?
  댓글 수: 1
Image Analyst
Image Analyst 2017년 6월 21일
Yes, probably. You can post the code in a new question.

댓글을 달려면 로그인하십시오.


Mohammad Sohail Khan
Mohammad Sohail Khan 2017년 11월 3일
편집: DGM 2023년 3월 4일
t = 0:pi/100:40;
x = cos(pi/10*t)+0.5*randn(size(t));
plot(t,x)
Then you know where pi/2, 3pi/4 etc are.

Adewale Obaro
Adewale Obaro 2018년 9월 24일
편집: DGM 2023년 3월 4일
N = 1000;
t = 0:1/N:2;
x = sin(2*pi*5*t);
Noise = x + randn(1,N)';
plot(t,Noise);
title('Noise in the Amplitude interval (0,0,1,0)');
ylabel('Amplitude [m]')
xlabel('Time [s]')

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by