This is the solution in MATLAB, please translate to Python 3. 1. (5 points) Prog
ID: 2290875 • Letter: T
Question
This is the solution in MATLAB, please translate to Python 3.
1. (5 points) Programming exercise.] Consider an LTI system with a transfer function .98 sin(?/24): 22-1.96cos(T/24) + .9604 Its impulse response is given by h[n] - .98" sin(Tn/24)u[n] Suppose that this system has the following signal as input: r[n] = ?(99)" cos(nn/48)u [n] Since both h[n] and r[n] decay to zero, we can approximate them as L-point signals (i.e., keep their first L samples) when L is sufficiently large. For this problem, let us choose L 512 (so, r[n]| and h[n| are truncated and represented by their respective samples for 0 S n 511) (a) (1 point) Directly co mpute the convolution of an] and hin] and plot the resulting ydir [n In Python, you may want to use 'np.convolve(x,h)'; you will also need to import numpy scipy and matplotlib.pyplot. (b) (3 points) Implement the convolution of x[n] and hm] using the following scheme Padding L zeros h[n] FFT Yfastln] IFFT Paddingx[n] L zeros xIn] FFT To compute the 1024-point FFT of h[n] in Python, you could use 'np.fft.fft (y)/N' (same for x[n]; N = 1024). IFFT is called in a similar way ?npft.ift(Y)'). Plot the resulting yfast[n] on the same graph as ydir [nExplanation / Answer
clc;
close all;
clear all;
%QUESTION a figure(1);
n = 0:1:511;
hn = (0.98).^n .* sin(pi*n/24);
subplot(3,1,1);
stem(n,hn); xn = (n.^2).*(0.99.^n).*cos(pi*n/48);
subplot(3,1,2);
stem(n,xn);
m = 0: 1 : length(xn)+length(hn)-2;
ydirn = conv(xn,hn);
subplot(3,1,3);
stem(m,ydirn);
%QUESTION b n = 0:1:1023;
figure(2); hn = (0 < n < 511).*(((0.98).^n) .*
sin(pi*n/24)) + (n > 511).*0;
Hfft = fft(hn,1024);
subplot(3,1,1);
stem(n,Hfft);
xn = (0 < n < 511).*(n.^2).*(0.99.^n).
*cos(pi*n/48) + (n > 511).*0
; Xfft = fft(xn,1024);
subplot(3,1,2);
stem(n,Xfft);
Yconv = Hfft.*Xfft;
yfastn = ifft(Yconv);
m1 = 0: 1 : length(Yconv)-1;
subplot(3,1,3);
plot(m1,yfastn,'r',m,ydirn,'b');
%QUESTION c L = 1:1:1000
; figure(3); ndir = 2*(L.^2);
nfast = 12*L.*log2(2*L) + 8*L + 4;
plot(L,ndir,'r',L,nfast,'b');
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.