![]() |
![]() |
|
|
| <<Home | Lab 3 | |||
|
Convolution
Example 1 From the file menu, open a new m file. Type the following MATLAB program Save this file with extension m (eg. dsp1.m) Return to command window and type "dsp1" (name of the saved file) and enter Enter the requested data as a= [-2 0 1 -1 3] b= [1 2 0 -1] Solution a = input('Type in the first sequence = '); b = input('Type in the second sequence = '); c = conv(a,b) M = length(c)-1; n=0:1:M; disp("Out put sequence = "); disp(c) stem(n,c) xlabel('Time Index n') ylabel('Amplitude') Result Out put sequence = c = -2 -4 1 3 1 5 1 -3
Convolution
Exercise 1 Repeat example 1 with a = [1 2 1 -1] b = [1 2 3 1] Result Out put sequence = c = 1 4 8 8 3 -2 -1
Signal y[n] is expanding and z[n] is not expanding (and found symmetry in +ve and -ve direction). Impulse response
Example 2a Find impulse response and step response of the following LTI system: y[n] + 0.7y[n-1] - 0.45y[n-2] - 0.6y[n-3] = 0.8x[n] - 0.44x[n-1] + 0.36x[n-2] + 0.02x[n-3] Solution p=[0.8 -0.44 0.36 0.02]; d=[1 0.7 -0.45 -0.6]; N=41; x=[1 zeros(1 ,N-1)]; y=filter(p,d,x); k=0:1:N-1; stem(k,y) xlabel('Time Index n') ylabel('Amplitude') Result
Step response
Example 2b To determine the step response replace in the above program the statement x=[1 zeros(1 ,N-1)] with x=[ones(1,N)]. Solution p=[0.8 -0.44 0.36 0.02]; d=[1 0.7 -0.45 -0.6]; N=41; x=[ones(1,N)]; y=filter(p,d,x); k=0:1:N-1; stem(k,y) xlabel('Time Index n') ylabel('Amplitude') Result
Unit ramp response
Exercise 2a Determine and sketch unit ramp response of the system given in example 2, i.e. y[n] + 0.7y[n-1] - 0.45y[n-2] - 0.6y[n-3] = 0.8x[n] - 0.44x[n-1] + 0.36x[n-2] + 0.02x[n-3] Solution p=[0.8 -0.44 0.36 0.02]; d=[1 0.7 -0.45 -0.6]; n=0:1:7; y=filter(p,d,n); stem(n,y) xlabel('Time Index n') ylabel('Amplitude') Result
Impulse & Step response
Exercise 2b Sketch the impulse and step response of the system described by the difference equation: y[n] = 0.7y[n-1] - 0.1y[n-2] + 2x[n] - x[n-2] Solution %Unit Response p=[2 0 -1]; d=[1 -0.7 0.1]; N=41; x=[1 zeros(1 ,N-1)]; y=filter(p,d,x); k=0:1:N-1; stem(k,y) xlabel('Time Index n') ylabel('Amplitude') %Step Response q=[2 0 -1]; e=[1 -0.7 0.1]; M=41; xx=[ones(1 ,M)]; yy=filter(q,e,xx); n=0:1:M-1; figure,stem(n,yy) xlabel('Time Index n') ylabel('Amplitude') Result Impulse response
Step response
Impulse response
Exercise 2c Sketch the response of the system characterized by the impulse response h[n] = (1/2)nu[n] to the input signal. 1 0<=n<=10 x[n] = 0 otherwise Solution n=0:1:10; x = (1/2).^n; m=ones(1,10); y=conv(x,m) l = length(y)-1; n=0:1:l; stem(n,y) Result
HELP CONV CONV
Convolution and polynomial multiplication. LENGTH
LENGTH Length of vector. FILTER
FILTER One-dimensional digital filter. ONES
ONES Ones array. ZEROS
ZEROS Zeros array. DSP Lab 1 DSP Lab2 DSP Lab 3 DSP Lab4 DSP Lab 5 DSP Lab 6 DSP Lab7 DSP Lab8 DSP Lab9 DSP Lab10 Other material |
||||
| <<Home | ||||
|
||||||