You are on page 1of 1

7/3/21 9:20 PM F:\DSP_LAB_6TH_SEM\EXP5\randomfilterd.

m 1 of 1

clear all;
close all;
clc;
fs=4000;
ft=2000;
t=0:1/fs:6;
x=randn(size(t));
figure;
subplot(3,2,1);
plot(t,x);

sound(x,fs);
xlabel('time');
ylabel('amplitude');
title('random signal');

y=abs(fft(x));
n=length(t);
y1=fftshift(y);
f1=(-n/2:n/2-1)*fs/n;

power1=abs(y1).^2/n;
subplot(3,2,2);
plot(f1,power1);
ylabel('power');
xlabel('frequency');
title('freq spectrum of random signal');
[num,den]=butter(2,2*1000/fs,'low');
y1=filter(num,den,x);

sound(y1,fs);
subplot(3,2,3);
plot(t,y1);

ylabel('amplitude');
xlabel('time');
title('filtered signal');

y=abs(fft(y1));
power0=abs(fftshift(y)).^2/n;
subplot(3,2,4);
plot(f1,power0);
ylabel('power');
xlabel('frequency');
title('freq spectrum of filterd signal');

You might also like