Digital Signal Processing4.4
Digital Signal Processing4.4
Digital Signal Processing4.4
4 Exercises:
a) Generation of unit impulse. Code:
k1 = -5; k2 = 10; k = k1:k2; x = (k==0); stem(k, x) xlabel('k') ylabel('\delta_k') title('Unit impulse sequence') axis([k1 k2 -0.1 1.1])
Output:
Output:
(for N=5)
Output:
Output:
p=x+y; clf; % Clear old graph stem(p,x); % Plot the generated sequence axis([0 40 -2 2]); grid; title('corrupted Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis;
Output:
5.4 Exercises
a). Convolve a[n]=[-2 0 1 -1 3] and b[n]=[1 2 0 -1] CODE:
a=[-2, 0, 1 ,-1 ,3]; subplot(3,1,1) stem(a) title('Discrete signal a') b=[1,2,0,-1]; subplot(3,1,2) stem(b) title('Discrete signal b') ylabel('Amplitude') c=conv(a,b); subplot(3,1,3) stem(c) xlabel('[n]') title('The convulation result of a and b') OUTPUT
b).Convolve x[n]=exp(j*pi/13*m) and h[n]=[1 1] when the value of j=1 and m=1. CODE:
j=1 m=1 h=[1,1] subplot(3,1,1) stem(h) title('Discrete signal h') l=exp(j*pi/13*m) subplot(3,1,2) stem(l) title('Discrete signal l') o=conv(h,l) subplot(3,1,3) title('The convulation result of h and l') xlabel('n') stem(O)
OUTPUT
OUTPUT
OUTPUT
EXERCISE: 9.4
a) Write a MATLAB program to compute the first L samples of the inverse of a rational z-transform where the value of L is provided by the user through the command input.
Answer: L=input('Input the samples of the inverse transform: L= '); num = [2 5 9 5 3]; den = [5 45 2 1 1]; stem(impz(num,den,L)); title(['The inverse transform with Samples with ',num2str(L),'Samples']) xlabel('Time ')
Using this program, compute and plot the first 50 samples of the inverse of any G(z). Use the command stem for plotting the sequence generated by the inverse transform.
G(z) =4-9.3z-1 -0.66z-2-z-3-0.59z-4 1-0.95z-1+0.18z-2+0.66z-3-0.32z-4
b) Write a MATLAB program to determine the partial fraction expansion of a rational z-transform.
Answer: num = [2 5 9 5 3]; den = [5 45 2 1 1]; [r,p,k]=residuez(num,den); disp('r='),disp(r); disp('p='),disp(p); disp('k='),disp(k);
Using this program, determine the partial fraction expansion of any G(z) and then its inverse z-transform g[n] in closed form. Assume g[n] to be a causal sequence.
G(z) =4-9.3z-1 -0.66z-2-z-3-0.59z-4 1-0.95z-1+0.18z-2+0.66z-3-0.32z-4 The partial fraction expansion of G(z) is as follows: r= 0.3109-1.0254 - 0.3547i-1.0254 + 0.3547i-0.8601 p= -8.95760.1147 + 0.2627i0.1147 - 0.2627i-0.2718 k= 3.0000 The inverse z-transform g[n] from this partial fraction expansion is as follows: G(z)= 0.31 + 1-(-8.96)z-1 -1.03-0.35i 1-(0.11+0.26i)z-2 + -1.03+0.35i 1-(0.11-0.26i)z-3 + -0.86 +3 -4 1-(-0.27)z
EXERCISE# 7.4
Proof: Let
, i.e.,
, we have
Proof: Let
, i.e.,
, we have
Proof of (a):
Proof of (b):
Exercise 13.4
a- Create the GUI with buttons and axes for the following: Convolution: button for x[n], and a button for y[n] = x[n]*h[n]. Also show the figure of above three sequences in axes. OUTPUT:
Button 1 coding:
x =[-2 0 1 -1 3]; stem(x); axes(handles.axes1);
Button 2 coding:
h=[1 1 1]; stem(h); axes(handles.axes2);
Button 3 coding:
x =[-2 0 1 -1 3]; h=[1 1 1]; y=conv(x, h); stem(y); axes(handles.axes3);
Convolve x[n] and h[n] in frequency domain and show them using buttons and axes.
Button 1 coding:
x =[-2 0 1 -1 3]; x1=fft(x); plot(x1); axes(handles.axes1);
Button 2 coding:
h=[1 1 1]; h1=fft(h); plot(h1); axes(handles.axes2);
Button 3 coding:
x =[-2 0 1 -1 3]; h=[1 1 1]; y=(ifft(fft(h).*fft(x))); plot(y);
axes(handles.axes3);
Convolve x[n] and h[n] in z transform domain and show them in separate bottons and axes.
Button 1 coding:
x =[-2 0 1 -1 3]; x1=czt(x); plot(x1); axes(handles.axes1);
Button 2 coding:
h=[1 1 1]; h1=czt(h); plot(h1); axes(handles.axes2);
Button 3 coding:
x =[-2 0 1 -1 3];