How do I change the amount of noise I want to add to a signal?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a clean signal from a wav file (of length y) and am trying to add noise to it to test a filter. The amplitude of the signal ranges from -1 to +1 so I have added noise that ranges between -1 and +1. To create the noise I have used a random number generator. However this fills the entire 'noise' matrix with values when all I want is every tenth or 20th value (e.g. for 10% or 5% noise) to be noisy and the rest of the elements in the noise matix to be zero.
noise = zeros(size(y));
n = 3; %number of decimal places in noise elements(below)
noise = randi([-1,1]*10^n,[size(y),1])/10^n;%creates noise between -1 and +1
noisySignal = y + noise; %y is clean signal, noise is what I've generated
Any ideas on how to achieve this? Thanks
0 comentarios
Respuestas (1)
Krishna Zanwar
el 1 de Mzo. de 2019
One method to do it is:
>> noise = randi([-10,10]*10^n,[20,1])/10^n
>> for i=1:size(noise)
>> if noise(i)>9
>> b(i)=noise(i)-9;
>> elseif noise(i)<-9
>> b(i)=noise(i)+9;
>> else
>> b(i)=0;
>> end
>> end
0 comentarios
Ver también
Categorías
Más información sobre Audio Processing Algorithm Design en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!