to generate a noise signal
조회 수: 6 (최근 30일)
이전 댓글 표시
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 Center 및 File Exchange에서 Code Generation and Deployment에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!