필터 지우기
필터 지우기

to generate a noise signal

조회 수: 6 (최근 30일)
maulik bhagat
maulik bhagat 2022년 9월 11일
댓글: Jeffrey Clark 2022년 9월 13일
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
Jeffrey Clark
Jeffrey Clark 2022년 9월 13일
@maulik bhagat, I think your randn(1,size(y,1:N)) should be randn(size(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