フィルターのクリア

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 Center および File ExchangeCode 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