All All
All All
All All
m 1 of 2
clear all;
close all;
clc;
ft=2000;
fp=200;
fs=600;
rp=1.938;
rs=13.98;
wp=(fp*2)/ft;
ws=(fs*2)/ft;
fss=2200;
t=0:1/fss:5;
n=length(t);
t1=0:0.0001:0.1;
[N,wn]=buttord(wp,ws,rp,rs);
[num,den]=butter(N,wn);
y1=sin(2*pi*100*t1);
subplot(3,2,1);
plot(t1,y1);
xlabel('time');
ylabel('amplitude');
title('signal of frequency 100hz')
sound(y1);
y2=sin(2*pi*1000*t1);
subplot(3,2,2);
plot(t1,y2);
xlabel('time');
ylabel('amplitude');
title('signal of frequency 1khz')
sound(y2);
y=sin(2*pi*1000*t1)+ sin(2*pi*100*t1);
subplot(3,2,3);
plot(t1,y);
ylabel('amplitude');
xlabel('amplitude');
title('signal of frequency 1khz and 100hz ')
sound(y);
y=sin(2*pi*1000*t)+ sin(2*pi*100*t);
fo=(-n/2:n/2-1)*fss/n;
m=abs(fft(y));
m1=fftshift(m);
power0=abs(m1).^2/n;
subplot(3,2,4);
7/3/21 9:18 PM F:\DSP_LAB_6TH_SEM\EXP5\combined_signal.m 2 of 2
plot(fo,power0);
ylabel('amplitude');
xlabel('frequency');
title('frequency spectrum of combined 1khz and 100hz ');
yt=filter(num,den,y);
x1=abs(fft(yt));
x=fftshift(x1);
power1=abs(x).^2/n;
subplot(3,2,5);
plot(fo,power1);
ylabel('amplitude');
xlabel('frequency');
title('freq spectrum of filterd signal');