

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
BJT Transistor ModelingBJT Transistor ModelingBJT Transistor ModelingBJT Transistor ModelingBJT Transistor ModelingBJT Transistor Modeling
Typology: Cheat Sheet
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Objective: The objective of this experiment is to learn how to convolve two signals using Matlab. Preliminary Work : Please review material about convolution from textbook or your notes. Part I: Signals Perspective For two discrete-time signals x[n] and h[n] that are both of finite length, you can implement the convolution operation y[n] = x[n] * h[n] in Matlab using the command conv. The resulting Matlab array that holds the values of y[n] will have a length equal to the length of x[n] plus the length of h[n] minus one. Here is an example problem: suppose that x[n] = δ[n] - 2δ[n - 1] + 3δ[n - 2] - 4δ[n - 3] + 2δ[n - 5] + δ[n - 6] and h[n] = 3δ[n] + 2δ[n - 1] + δ[n - 2] - 2δ[n - 3] + δ[n - 4] - 4δ[n - 6] + 3δ[n - 8]. The problem is to use Matlab to compute the convolutions y1[n] = x[n] * h[n] and y2[n] = x[n — 3] * h[n]. Here is the solution for the example problem: The signal x[n] "goes" from n = 0 to n = 6, so the shifted signal x[n — 3] "goes" from n = 0 to n = 9. This means that we need a Matlab array with 10 elements to hold the values of x[n — 3] (for n = 0,1,..., 9). To make the plotting easy, we will store both x[n] and x[n — 3] in 10-element Matlab arrays. Since h[n] "goes" from n = 0 to n = 8, we will need a nine-element Matlab array to hold the values of h[n]. Each convolution result will have a length of 10 + 9 - 1 = 18, corresponding to the "times" n = 0 , 1 ,... , 1 7. Here is sample Matlab code to compute the two convolutions and plot them both in the same figure using the subplot command: x = [1 - 2 3 - 4 0 2 1 0 0 0]; % Input signal zero-padded to length 10 xm3 = [0 0 0 1 - 2 3 - 4 0 2 1]; % Shifted input signal x[n-3] h = [3 2 1 - 2 1 0 - 4 0 3]; % Impulse response y1 = conv(x,h); % Make y1[n] = x[n] * h[n] y2 = conv(xm3,h); % Make y2[n] = x[n-3] * h[n] n = 0:17; % "time" values for x-axis of plot
subplot(2,1,1); % Make a 2x1 array of graphs and make % the first graph the "current" one stem(n,y1); % Plot y1 against n title('y_1[n] = x[n] * h[n]'); % Title for top graph xlabel('n'); % X-axis label for top graph ylabel('y_1[n]'); % Y-axis label for top graph subplot(2,1,2); % Select the second graph as "current" stem(n,y2); % Plot y2 against n title('y_2[n] = x[n-3] * h[n]'); % Title for bottom graph xlabel('n'); % X-axis label for bottom graph ylabel('y_2[n]'); % Y-axis label for bottom graph Now it's your turn. Let x[n] = δ[n] + 3δ[n - 2] + δ[n - 3] + 2δ[n - 4] - δ[n - 5] and h[n] = 2δ[n] + 2δ[n - 2]. (a) Write Matlab code to compute and plot the following convolutions: y1[n] = x[n] *h[n] and y2[n] = x[n — 2] * h[n].