Sie sind auf Seite 1von 3

Lab #6 (Convolution in continuous-time)

In this lab, you will learn how use MATLAB to perform the convolution operation for in
continuous-time. MATLAB does have a built-in convolution function, conv, but it is
only available for discrete-time. Discrete time systems will be discussed in Signals and
Systems II. However, we can use the conv function to implement our own continuous-
time convolution function. You will need to generate this function for the general case.
The function you write will be called ConvCT.

1. Making a step function.

~
Write a function, u (t ) , called MyStepFunc that implements a (close to ideal) step
function. Note that the ideal step function has no value at t=0.
~
Function u (t ) is
described as follows:

~ (t ) 1 if t 0
u
0 otherwise

The function MyStepFunc must have a vector input, time. To implement the function,
built-in functions, such as ones and length, etc. will be very useful. In addition,
control statements such as for, if and else can be used, if needed. Call your
function with t = -10:0.0001:5. Plot the outputs of your MyStepFunc with the correct
time vs. magnitude axes. Include labels for both axes and put an appropriate title.

2. Convolution in continuous-time

2.1 Type the lines below in a new editing window. Note that the Clear all
statement means that all variables will be cleared (deleted). A time vector, t, is
generated from -10 to 10 seconds at a 0.01 sec increment.

clear all
T0 = -10; Tstep = 0.01; Tf=10;
t=T0:Tstep:Tf;
2.2 Write a couple of lines to generate the two waveforms shown in the figures
below. Note that x(t) and h(t) can be generated using your own step function
from Step 1.
2.3 Convolve the two functions, x(t) and h(t), using the built-in discrete time
convolution, conv. Study the functionality of conv using the doc and/or
help commands. Note that you have to multiply the results of obtained
with the conv function with Tstep, to account for the fact that we are
using a discrete-time function for a continuous-time operation.

2.4 Plot the result of the convolution. You will notice that the x-axis of your result
does not use the correct time index. To adjust it, include the code shown below
to your code. In the following code, y stands for the result of the convolution
operation.
NonzeroIndxH = find(h>0);
NonzeroIndxX = find(x>0);
NonzeroIndxY = find(y>0);
%% For new time axis of the convolution result
n =1:1:length(y);
Newn = n - NonzeroIndxY(1);
Match = t(NonzeroIndxH(1))+t(NonzeroIndxX(1));
NewT= Match+Newn*Tstep;

Explain why you need the following line to generate a correct time index.
Match = t(NonzeroIndxH(1))+t(NonzeroIndxX(1));

_____________________________________________________________________________

_____________________________________________________________________________

_____________________________________________________________________________
2.5 Plot the convolution result, y, with the new time index, NewT, generated in step
2.4. Verify whether your plot does display the right time index (or not).
3. Lab report
For your Lab report, print out all supporting documents from Steps 1 and 2. Using the
functions in these steps, create your own convolution function in continuous-time,
which will be called ConvCT. Your function, ConvCT, must have five inputs: x(t),
h(t), T0, Tf, and Tstep. In addition, your function, ConvCT must have two outputs, y
and NewT, where y is the convolution result and NewT is the x-axis that will be
needed to plot y. Test your function for the following two functions. In addition, check
your function with one other x(t) and h(t) used either in the textbook or in homework.
Submit all your test results and codes in the lab report.

x(t ) 2[u (t 2) u (t 4)]


h(t ) (t 2)[u (t ) u (t 2)]

Das könnte Ihnen auch gefallen