Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Filter Implementation and Analysis -Matlab Use the function filter to implement

ID: 2081610 • Letter: F

Question

Filter Implementation and Analysis -Matlab

Use the function filter to implement the following FIR filter w[n] = x[n] - 0.85x[n - 1] on the input signal x[n] that is created with the following MATLAB statement: >> xx = rem (0:99, 30) > 10; (a) Explain how the MATLAB command that generates the signal x[n] works. How would you modify this statement to create a sequence of ten zeros followed by ten ones, and have this repeat for five cycles? (b) Plot both the input and output waveforms x[n] and w[n] on the same figure, using the subplot and stem functions. (c) Explain why the output appears the way it does by figuring out (mathematically) the effect of the filter coefficients in Eq. (5) on x[n].

Explanation / Answer

a) rem function is the remainder function such that output of rem(a,b) = a%b.
In the above case, a is an array [0:99] and b = 30. Hence, rem(0:99,30) will be 0:29,0:29,0:9.
Now, rem(0:99,30)>10 will be 0(10 times),1(20 times),0(10 times),1(20 times),0(10 times),1(20 times),0(10 times).

Now to make it a sequnce of 10 zeros and 10 ones, and 5 such sequences, we need to have rem(0:99,20)>10.

the output, y(n) = x(n) - 0.85x(n-1).
x(n-1) is the x(n) time shifted by 1 unit.

b)

clc;
close all;
clear all;

xx = rem(0:99,30)>10;
stem(xx);

xx = rem(0:99,20)>10;

B = [1 -0.85];
A = [1];
Y = filter(B,A,xx);

figure
subplot(2,1,1);
stem(xx);

subplot(2,1,2);
stem(Y);

c) We know, x(n) is a sequence of 10 zeros and 10 ones, and 5 such sequences.
At n = 10, y(10) = x(10) - 0.85 x(9) = 1 - 0 = 1
At n = 11, y(11) = x(11) - 0.85 x(10) = 1 - 0.85 = 0.15
At n = 20, y(20) = x(20) - 0.85 x(19) = 0 - 0.85 = -0.85
At n = 21, y(21) = x(21) - 0.85 x(20) = 0 - 0.85 = 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote