In: Electrical Engineering
Matlab Code that does the following:
Takes as input 3 frequencies.
Create a signal that is a mixture of the 3 signals. Create a bandpass filter that only selects the center
frequency.
Output the filtered signal which contains only the middle frequency.
Plot in time and frequency domain the original signal and the filtered signal. Show the output for filter
order 1 and 15. Upload a pdf of the image files. Each figure should have your name in the title of the
submission.
clc
clear all
close all
fs = 600;
t = 0:1/fs:.5;
N=10;
x = sin(2*pi*50*t)+sin(2*pi*150*t)+sin(2*pi*250*t);
d=fdesign.bandpass('N,F3dB1,F3dB2',N,100,200,fs);
Hd=design(d,'butter');
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('Filtered signal')
xlabel('time')
ylabel('Amplitude')
figure;
freq=0:(2*pi)/length(x):pi;
X=fft(x);
Y=fft(y);
plot(freq,abs(X(1:length(x)/2+1)))
hold on
plot(freq,abs(Y(1:length(x)/2+1)),'-r')
hold off
xlabel('Normalized Frequency (\times\pi rad/sample)')
legend('Original Signal','Bandpass Signal')
title(['Frequency Response of input and filtered signal for order
N=',num2str(N)])
For N=10;
For N=1;
In the title you can add your name. Change N value to change the order which will give you corresponding plot.