How do I change the amount of noise I want to add to a signal?
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Krishna Zanwar
2019년 3월 1일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio Processing Algorithm Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!