In: Physics
Realize signal processing systems described by the difference equation: ?1(?)=1/2 [?(?)+?(?−1)] and ?2(?)=1/2 [?(?)−?(?−1)] using Matlab. Assuming same input signal x(n)=sin(ωn) for various values of ω ={0,p/6 ,3p/2, 1.9p/2} applied to both systems find the following: a. Obtain stem plots and codes of y1(n) and y2(n) in each . b. Critically analyze y1(n) and y2(n) in terms of type of filter, maximum gain and cut off frequency. (Hint : The system can be tested by computing frequency response of the system).
Solution:
Given that
EXECUTABLE CODE:
clc;
clear all;
close all;
% first define w
w = [0 pi/6 3*pi/2 1.9*pi/2];
% define n
n = 0:100;
% define system 1 and system 2
num1 = [12 12];
den1 = 1;
num2 = [12 -12];
den2 = 1;
% filtering for various w
for k = 1:length(w)
x = sin(w(k)*n);
% now filter the signal with filter #1
y1 = filter(num1,den1,x);
% now filter the signal with filter #2
y2 = filter(num2,den2,x);
% now plot the filtered signals
figure;
subplot(211);
stem(n,y1);xlabel('n');
title(['filtered signal from system 1 for w =
',num2str(w(k))]);
subplot(212);
stem(n,y2);xlabel('n');
title(['filtered signal from system 2 for w =
',num2str(w(k))]);
end
% Now plot the frequency responses of the filteres
figure;
freqz(num1,den1);grid on;
title('frequency response the filter 1');
figure;
freqz(num2,den2);grid on;
title('frequency response the filter 2');
OUTPUT: