to generate a noise signal

6 次查看(过去 30 天)
maulik bhagat
maulik bhagat 2022-9-11
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)

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Code Generation and Deployment 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by