- The Matlab command to generate a discrete-time plot is
`stem`

. An example of its use follows:ramp = 1:10; stem(ramp)

Here is an example to plot*y*[*n*] = 2^{n}for*n*= 0 to*n*= 5:nn = 0:5; yy = 2 .^ nn; stem(nn,yy)

Note the use of the period in front of the arithmetic operation ^. The .^ operator means to operate on each element in the vector argument(s) separately. You can get more information on the stem function by typinghelp stem

- Problem 5.2(a):
Please use an amplitude of one for each rectangular pulse.
Your answer should not have any summation terms in it.
It might help to convolve two short rectangular pulses of different lengths, e.g. length two samples and length three samples, to see the trend.

Appendix E in the course reader, on pages E-2 and E-3, contains a worked example of convolving two discrete-time rectangular pulses of the same length to produce a triangular pulse.

The convolution result will be a trapezoid when L

_{1}is not equal to L_{2}. The plateau in the trapezoid will have | L_{1}- L_{2}| + 1 samples in it, which can be rewritten as max(L_{1}, L_{2}) - min(L_{1}, L_{2}) + 1. As a sanity check, when L_{1}= L_{2}, the convolution result is a triangular pulse and the plateau in the trapezoid would be one sample long. - Problem 5.2(b):
We can write a piecewise function as a formula, and
the convert the formula to Matlab code.
Here is an example of a triangular pulse in continuous time:
/ t for 0 ≤ t < 5 x(t) = | \ 10-t for 5 ≤ t < 10

We can write this as formula by using a rectangular pulse to enforce each interval:x(t) = t ( u(t) - u(t-5) ) + (10-t) ( u(t-5) - u(t-10) )

We can then convert this to Matlab code:t = -1 : 0.01 : 11; x = t .* ( stepfun(t,0) - stepfun(t,5) ) + (10-t) .* ( stepfun(t,5) - stepfun(t,10) ); plot(t,x);

- Problem 5.3(a):
To find out the initial condition(s),
we first set n = 0:
y[0] = x[0] + y[-1]

The only initial condition is y[-1]. We then set n = 1:y[1] = x[1] + y[0]

There are no initial conditions in the expression for y[1]. - Problem 5.4(a):
We can determine w0 by sampling a continuous-time sinusoid
at a sampling rate of Fs:
y(t) = cos(2 pi F0 t) Since Ts = 1 / Fs, we have t = n Ts = n / Fs,

y[n] = y(t) |_{t = n Ts}y[n] = y(t) | So, w0 = 2 pi F0 / Fs._{t = n / Fs}

y[n] = cos(2 pi F0 (n / Fs))

y[n] = cos(2 pi (F0/Fs) n)

Last updated 09/29/10. Send comments to bevans@ece.utexas.edu