Filter löschen
Filter löschen

to generate a noise signal

6 Ansichten (letzte 30 Tage)
maulik bhagat
maulik bhagat am 11 Sep. 2022
Kommentiert: Jeffrey Clark am 13 Sep. 2022
Read any audio file given and play it from Matlab. Find the
number of samples N in the audio file. Generate a noise signal of length N in which
each sample is from a Gaussian distribution with mean 0 and variance 1. Add the
noise signal in the audio and listen it from Matlab.
Pass the noisy signal generated abouve through a MA filter with M1 = M2 = 2 and
generate the output. Listen the output signal and comment on your observation.
code giving randn error.
[y,Fs] = audioread('hello.mp3');
N = length(y);% Number of sample in y;
variance = 1;
mean=0;
W = sqrt(variance).*randn(1,size(y,1:N))+mean; %Gaussian white noise W
y =y + W; %Add the noise
M1=2;
M2=2;
r = ones(1,M1+M2+1);
impulse_response = (1/M1+M2+1).*r;
for k=-M1:M2
y(k)=.5*y(k) + .5*y(k-1); % taking successive average
end
w = -pi:pi/100:pi;
l=length(y);
k=length(impulse_response);
H=[y,zeros(l+1)];
X=[impulse_response,zeros(k+1)];
for i=1:l+k-1
Y(i)=0;
for j=1:k
if(i-j+1>0)
Y(i)=Y(i)+H(i-j+1)*X(j);
end
end
end
sound(Y,Fs);
plot(w,Y)
  1 Kommentar
Jeffrey Clark
Jeffrey Clark am 13 Sep. 2022
@maulik bhagat, I think your randn(1,size(y,1:N)) should be randn(size(y)) ?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Code Generation and Deployment finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by