Introduction to the convolution Experiment # 4 LTI S ystems & Convolution Amongst the concepts that cause the most confusion to electrical engineering students, the Convolution Integral stands as a repeat offender. As such, the point of this experiment is to explain what a convolution integral is, why engineers need it, and the math behind it. In essence, the convolution of two functions (over the same variable, e.g. f (t ) and f (t ) ) is an operation that produces a separate third function that describes how the first function modifies the second one. Conversely, the resulting function can be seen as how the second function modifies the first function. Sometimes the result is used to describe how much the first two functions have in common. In all honesty, the concept of the convolution of two functions is quite abstract, but the frequency at which it appears in nature grants its importance to scientists and engineers. Ultimately the aim here is to identify its use to electrical engineers so for now do not dwell solely on its mathematical significance. A convolution of two functions is denoted with the operator *, and is written as: f (t ) * f (t ) f ( ) * f (t Where τ is used as a dummy var iable. )d Before diving any further into the math, let us first discuss the relevance of this equation to the realm of electrical engineering. Why is the convolution integral relevant? Most electrical circuits are designed to be linear, time-invariant (LTI) systems. Being linear implies that the magnitude of a circuit s output signal is a scaled version of the input signal s magnitude. F urther, an LTI system that is excited by two independent signal sources will output the sum of the scaled versions of each signal. This is extended for an infinite number of independent signal sources, and gives rise to the concept of superposition. P ut in another way, if a function x (t ) causes an LTI system to output y (t ), then: a.x (t ) a.y (t ) Where say: a is a multiplicative constant. In addition to this, superposition allows us to
a.x (t ) a.x (t )... a.y (t ) a.y (t )... Being a time- invariant system means it does not matter when the input signal is applied a specific input signal will always result in the same output signal for a given LTI system. P ut mathematically, time- invariance can be expressed as: x (t ) y (t ) x (t ) y (t ) where τ can be viewed as a time delay when dealing with signals through time (i.e. time-domain signals ). Though not directly, this concept also signifies that an output signal cannot contain frequency components not inherent in the input signal (causality). The vast majority of circuits are LTI systems, each with a specific impulse response. The impulse response of a system is a system s output when its input is fed with an impulse signal a signal of infinitesimally short duration. A real- world impulse signal would be something like a lightning bolt or any form of ESD (electro-static dischage). Basically, any voltage or current that spikes in magnitude for a relatively short period of time may be viewed as an impulse signal. The impulse response of a circuit will always be a time-domain signal, and exists because no signal can propagate through a circuit in zero time; each individual electron involved can only move so quickly through each component. Typically, real-world electronic LTI systems exhibit an impulse response that consists of an initial spike in magnitude, followed by an everlasting and ever-decreasing exponential relationship in signal magnitude. So, here s the big deal: the fact that each LTI circuit has a specific impulse response function (here, referred to as h (t ) ) is very useful in predicting its behavior given a particular input signal (here, referred to as x (t ) ). This is because the input signal itself may be viewed as an impulse train a stream of continuous impulse functions, with infinitesimally short durations of time between each impulse. This fact, along with superposition, allows one to find the output of an LTI system given an arbitrary input signal by summing the LTI system s impulse response to each impulse function that make up the input signal. By allowing the time between each impulse of the input signal to go to zero, this approach can be used to determine the output timedomain signal of an LTI system for any time-domain input signal.
Useful Properties The following is a list of useful properties of the convolution integral that can help in developing an intuitive approach to solving problems:.) Commutative Property: f (t ) * f (t ) f (t ) * f (t ).) Distributive Property: f (t ) * f (t ) f 3 (t ) f (t ) * f (t ) f (t ) * f 3 (t ) 3.) Associative Property: f (t ) * f (t ) * f 3 (t ) f (t ) * f (t ) * f 3 (t ) 4.) Shift Property: if f (t )* f (t ) c (t ) then f (t T )* f (t T ) c (t T T ) 5.) Convolution with an Impulse results in the original function: f (t ) * (t ) f (t ) 6.) Width Property: The convolution of a signal of duration T and a signal of duration T will result in a signal of duration T 3 T T
Example : consider the system described by the differential equation: y (t ) y (t ) y (t ) f (t ) where y(t) is the output, and f(t) is the input. The impulse response of this system, h(t), can be shown to be equal to h (t ) 4 3e.5t sin( 4 3.t ), t (from Laplace Transform Table) The impulse response is shown graphically be low..6 Impulse response of system.4.3 Output.. -. 3 4 5 6 7 8 9 (sec) You know how to find the output y(t) if the input f(t) is a well defined input such as a step, impulse or sinus oid Convolution a llows you to determine the response to more complex inputs like the one shown below. In fact, you can use convolution to find the output for any input, if you know the impulse response. This gives incredible power.
3 Input vs Input - - -3 3 4 5 6 7 8 9 There are several ways to understand how convolution works. First convolution will be developed in an approximate form as the sum of impulse responses. This presentation is useful for an intuitive understanding of the convolution process. After the approximate form is developed, the exact analytic form of convolution is given. The convolution as a sum of impulse responses. To understand how convolution works, we represent the continuous function shown above by a discrete function, as shown below, where we take a sample of the input every.8 seconds. 3 Input vs and discrete approximation - - -3-4 6 8
The approximation can be taken a step further by replacing each rectangular block by an impulse as shown below. The area of each impulse is the same as the area of the corresponding rectangular block. 3 Input vs and approximation with impulses Input - - -3 3 4 5 6 7 8 9 The superposition theorem states that the response of the system to the string of impulses is just the sum of the response to the individual impulses. The response of the system to the individua l impulses is shown below. Response.5 Scaled and Delayed Impulse Response DT=.8 Delay Delay Delay 3 Delay 4 Delay 5 Delay 6 - - 3 4 5 6 7 8 9
The summed response is shown in the graph below, along with the individual responses. 3.5.5 Scaled and Delayed Impulse Response DT=.8 Delay Sum of impulses is shown in black Delay Delay 3 Delay 4 Delay 5 Delay 6 Response - - 3 4 5 6 7 8 9 Obvious ly if you decrease the accuracy of the approximation should improve. The graph below shows the impulse responses if we let Δ t=.3 seconds (instead of.8 seconds as shown above).
.6 Scaled and Delayed Impulse Response DT=.3.4 Response Response.3.. -. 3 4 5 6 7 8 9 The graph below shows our approximate response, for Δt=.8 and Δt=.3, along with the exact response (the "exact" response is actually a numerical approximation, as calculated by Matlab). 3.5.5 Sum of impulse responses Exact (lsim) DT=.8 DT=.3 - - 3 4 5 6 7 8 9 The graph below shows the "exact" response along w ith the response calculated us ing Matlab "conv" (convolve) function. Type "he lp conv" at the Matlab prompt to see how it works..
3.5 Exact response, and using Matlab's 'conv' function Exact (lsim) Using 'conv'.5 Response - - 3 4 5 6 7 8 9 Hopefully this background gives you some phys ical ins ight into how convolution can be used to find the response of the system to an arbitrary input. Look at the code in the appendix Note about the function" conv " We can calculate this important function for MATLAB sampled time series in a variety of ways, but the simplest method is to use the conv function, which simply multiplies and sums the two progressively time lagged series together (with one of the two time reversed; it doesn t matter which). If the two input series are of lengths N and M, then it s not hard to see that the resulting output is of length N +M -. To properly approximate the continuous integral defining convolution for sampled time series, we must multiply the raw output of conv by the sampling interval for the two time series, dt. For example, to calculate the convolution of the MATLAB vectors a and b, where the sampling rate is Hz, we simply wr ite c= conv(a, b)*. Visualizing the Convolution Integral
.5.5 - - x(t- ) t -.5 h( )x(t- ) - - -.5.5 3 3.5 4 h( ).5 y(t) = h( )x(t- ) d - - - -.5.5 3 3.5 4 t Check this site for continuous convolution http ://www.jhu.ed u/signa ls/le cture /fra mes. html Discrete convolution y n x n * h n x k k * h n k If arbitrary sequences are of infinite duration, then MATLAB cannot be used directly to compute the convolution. MAT LAB does provide a built-in function called conv that computes the convolution between two finite -duration sequences. The conv function assumes that the two sequences begin at n = and is invoked by :» y = conv(x,h); For example, given the following two sequences: x(n) = [3,,7,,-,4,], -3 n 3; h(n) = [,3,,-5,,], - n 4 determine the convolution y(n) = x(n) * h(n).»x = [3,, 7,, -,4,].» h = [, 3,, -5,, ];» y = conv(x,h) y = 6 3 47 6-5 -5 4 8 - -3 8
However, the conv function ne ither provides nor accepts any timing information if the sequences have arbitrary support. What is needed is a beginning point and an end point of y(n). Given finite duration x(n) and h(n), it is easy to determine these points. Let x (n ); n xb n n xe and h (n ); n hb n n he Then the beginning and end points of y n are for y(n) n yb n xb n hb and n ye n xe n he A simple extension of the conv function, called conv_m, which performs the convolution of arbitrary support sequences can be designed. function [y,ny] = conv_m(x,nx,h,nh) % Modified convolution routine for signal processing % ------- DSP LAB / Computer Engineering / IUG ------- % [y,ny] = conv_m(x,nx,h,nh) % [y,ny] = convolution result % [x,nx] = first signal % [h,nh] = second signal nyb = nx()+nh(); nye = nx(length(x)) + nh(length(h)); ny = [nyb:nye]; y = conv(x,h); now resolve the previous convolution us ing the conv_m function. Solution: x =[3,, 7,, -, 4, ]; nx =[-3:3]; h =[, 3,, -5,, ]; nh = [-:4]; [y,ny] =conv_m(x,nx,h,nh) subplot(3,,) stem(nx,x) xlabel('n') ylabel('x[n]') subplot(3,,) stem(nh,h) xlabel('n') ylabel('h[n]') subplot(3,,3) stem(ny,y) xlabel('n') ylabel('y[n]') y = 6 3 47 6-5 -5 4 8 - -3 8 ny= -4-3 - - 3 4 5 6 7 Hence y(n) = {6,3,47,6, -5, -5, 4, 8, -, -3, 8, } Check this site for discrete convolution http://www.jhu.edu/signals/discreteconv/index.html
Amplitude Part Discrete Convolution : x=[- 3 - ]; h=[- - ]; y=conv(x,h); stem(y,'r','linewidth',.5) axis([- - ]) grid on xlabel('') ylabel('amplitude') title('discrete convolution') Discrete convolution 8 6 4 X= Y= - -4-6 -8 - - 4 6 8
function [y,yn]=convolution(x,xn,h,hn) y=conv(x,h); yns=xn()+hn(); yne=xn(length(x))+hn(length(h)); yn=[yns:yne];
Amplitude after modified function x=[- 3 - ]; xn=[-:]; h=[- - ]; hn=[-:3]; [y,yn]=convolution(x,xn,h,hn) stem(yn,y,'r','linewidth',.5) axis([-4 - ]) grid on xlabel('') ylabel('amplitude') title('discrete convolution') Discrete convolution 8 6 4 - -4-6 -8 - -4-4 6 8
Part t=-:.:4; T=-:.:8; x=hardlim(t+)-hardlim(t-); % x=((t>=-)&(t<)); h=(/3)*(t).*(hardlim(t)-hardlim(t-3)); y=(conv(x,h)).*.; subplot(,,) plot(t,x,'r','linewidth',.5) xlabel('time'); ylabel('amplitude'); title('input signal'); grid on axis([- 3 - ]) subplot(,,) plot(t,h,'b','linewidth',.5) xlabel('time'); ylabel('amplitude'); title('impulse response signal'); grid on axis([- 4 - ])
Amplitude Amplitude Amplitude subplot(,,) plot(t,y,'b','linewidth',.5) xlabel('time'); ylabel('amplitude'); title('impulse response signal'); grid on axis([-5-5 7]) input signal Impulse response signal.5.5 - - - 3 time.5 output signal - - 3 4 time - - - 3 4 5 time
Part 3: