

The signal (f400) behaves as a bandpass filter - there is %"n" so we can plot just the beginning part of z. %Because z is longer than y, create a new vector (All of theseĬommands are in the file Lab7_matlab_code.m).į400=sin(2*pi*400*t1).*exp(-40*t1) %A 400 Hz decaying sine wave. (note that the maximum frequency on the spectrogram is 4000 Hz because theĬreate a short sinusoidal signal (1/10 second) at 400 Hz, andĬonvolve it with the chirp. You can visualize the increasing frequency with a spectrogram These commands are in the file Lab7_matlab_code.m). (i.e., the frequency increases at 200 Hz/sec). (All of

Note: Compare your results with the convolutions on the web site to make sure you have correctly scaled the convolution sum.Ĭreate a chirp signal that goes from 0 to 2 kHz in 10 seconds Introduce an appropriate vector of time values so that the horizontal axis of your plot is correct. Then, perform the continuous-time convolutions using 'conv' and plot the result. Letting T=0.01, create vectors representing the three continuous-time signals on the "Joy of Convolution" web site, starting at t = 0 for each signal. Therefore, the sum must be multiplied by T to reflect the width of the sampling interval. The convolution integral can then be approximated by thinking of the sum performed by 'conv' as a Riemann sum. Create two new additional signals of your choice for x and h to test and demonstrate your convolution of arbitrarily shifted functions.Ĭ) Now look at the examples of continuous-time convolution at the "Joy of Convolution" web site To use 'conv' for continuous-time signals, the vectors representing the continuous-time signals are the values of the signals sampled at some period T. Then running the m-file will make the three plots. To run this m-file, you will first set x and h to one of the three vectors of values from part (a), and assign values to nx and nh. Write an m-file that plots x, h, and conv(x,h) with the correct time indices. (Since MATLAB always starts vector indices at 1, you will have to introduce a separate vector for the values of n.)ī) Suppose the signals in part (a) are shifted in time so that the first non-zero value of the signal x starts at nx and the first nonzero value of h is nh, where nx and nh are arbitrary integers. Plot your results with the correct values of n on the horizontal axis. Define your signals in an m-file, or save them so that you can reload them so that you can show the TA your work. To become familiar with this command, use it to compute some of the convolutions for the discrete-time signals on the "Joy of Convolution" web site To do this, create vectors representing the three discrete-time signals (beginning at n=0, the first non-zero value for each signal), and compute the convolutions using the 'conv' command. (d) Use MATLAB to verify your answer from Problem 2.21 (d).A) The MATLAB command 'conv' computes the convolution of two vectors. (c) Use MATLAB to calculate and plot the convolution y = z *h where x = u(n + 1] - u = u(-2-n] - u. (b) Use MATLAB to calculate and plot the convolution y = xin * h where x = 6 - is the signal depicted in Figure P2.24(b) on page 143 of the book. (a) Use MATLAB to calculate and plot the convolution y = x *h where | x = a = 8 +8.
MATLAB CONV FUNCTION CODE
The following MATLAB code replicates the results of the discrete-time convolution example that was presented in the supplemental video lecture posted online: nx = -3:0 nh = -1:2 ny = -4:2 x = h = y = conv(x,h) figure() subplot(3,1,1) stem(nx,x) xlim() xlabel('x') subplot(3,1,2) stem(nh, h) xlim() xlabel('h') subplot(3,1,3) stem(ny,y) xlim() xlabel('y = x *h ') In general, if a signal r is only non-zero on the interval a How- ever, you have to be careful about the indices. Transcribed image text: MATLAB problem: The conv function in MATLAB performs discrete-time convolution.