In: Electrical Engineering
3. For the following analog signal: xa(t) = 3sin(40πt) + 3cos(50πt) which is sampled at a rate of 100 samples/second. a. Design an IIR digital filter that will pass the first component 3sin(40πt) with attenuation of less than 1 dB and suppress the second component 3cos(50πt) at least 50 dB. The filter should be monotonic in the passband and have ripple in the stopband. ( 2 points ) b. Generate 500 samples of the sampled signal xa(t) at the given sampling rate and use the filter you designed to process the sampled signal using MATLAB’s ”filter” command. ( 1 point ) c. Plot the original signal and the output signal in one window using MATLAB’s subplot command ( in either a 1 X 2 arrangement or a 2 X 1 arrangement. Remember to title all plots and label all axes.
PLEASE SOLVE USING MATLAB
The given requirements demand a butterworth filter. This is because that a butterworth filter can produce a small passband ripple for a less order than the other filters with higher orders.
The design of the butterworth filter consists of obtaining the order of the filter followed by the filter coefficients. The MATLAB code given below does what's required.
% MATLAB code is given below in bold letters.
clc;close all;clear all;
% define the cutoff frequency
fc = 20; % 20 Hz
% define the stop frequency
fstop = 25; % 25 Hz
% define sampling frequency
fs = 100; % 100 Hz
% define the filter characteristics
Wp = fc/fs/2;
Ws = fstop/fs/2;
Rp = 1; % passband ripple
Rs = 50; % stopband ripple
% obtain the required order of the butterworth filter for
the given requirements.
[N, Wn] = buttord(Wp, Ws, Rp, Rs);
% obtain the filter coefficients
[b,a] = butter(N,fc/(fs/2));
% plot the frequency response of the filter
figure;freqz(b,a);
% now define the time sequence
t = 0:1/fs:99/fs; % 100 samples
% define the input signal
xa = 3*sin(40*pi*t) + 3*cos(50*pi*t);
% filter the signal
y = filter(b,a,xa);
% plot the input signals
figure;
subplot(211);
plot(t,xa,'linewidth',2);grid on;
xlabel('time');ylabel('Amplitude');title('Input signal');
subplot(212);
plot(t,y,'linewidth',2);grid on;
xlabel('time');ylabel('Amplitude');title('Output filtered
signal');
Frequency response of the filter:
Filter Input and Output: