In: Electrical Engineering
Pass the signal x5 through the filter h using the command: x6 = filter(h,1,x5); In your report, include a plot of the amplitude spectrum of x6 (use the normalized frequency axis as you did for previous parts of this project).
clc
clear all
close all
fs = 600; %Sampling frequency
t = 0:1/fs:.5;
N=10;
%Input Signal
x = sin(2*pi*50*t)+sin(2*pi*150*t)+sin(2*pi*250*t);
%Band Pass filter design
d=fdesign.bandpass('N,F3dB1,F3dB2',N,100,200,fs);
Hd=design(d,'butter');
%Filtering input signal with Bandpass filter
y=filter(Hd,x);
subplot(2,1,1)
plot(t,x)
title('Input signal')
xlabel('time')
ylabel('Amplitude')
subplot(2,1,2)
plot(t,y,'-r')
title('Band Pass Filtered signal')
xlabel('time')
ylabel('Amplitude')
figure;
freq=0:(2*pi)/length(x):pi;
X=fft(x);
Y=fft(y);
subplot(2,1,1)
plot(freq,abs(X(1:length(x)/2+1)))
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude')
title(['Frequency Response of input signal for order
N=',num2str(N)])
subplot(2,1,2)
plot(freq,abs(Y(1:length(x)/2+1)),'-r')
xlabel('Normalized Frequency (\times\pi rad/sample)')
ylabel('Magnitude')
title(['Frequency Response of filtered signal for order
N=',num2str(N)])
We can also design any type of filter using relevant filter model in the same way. Order of filter N can be changed to our requirement.