<< Chapter < Page Chapter >> Page >

This lab involves experimenting with the convolution of two continuous-time signals. The main mathematical part is written as a .m file, which is then used as a LabVIEW MathScript node within the LabVIEW programming environment to gain user interactivity. Due to the discrete-time nature of programming, an approximation of the convolution integral is needed. As an application of the convolution concept, echoes are removed from speech recordings using this concept.

Numerical approximation of convolution

In this section, let us apply the LabVIEW MathScript function conv to compute the convolution of two signals. One can choose various values of the time interval Δ size 12{Δ} {} to compute numerical approximations to the convolution integral.

Convolution example 1

In this example, use the function conv to compute the convolution of the signals x ( t ) = exp ( at ) u ( t ) size 12{x \( t \) ="exp" \( - ital "at" \) u \( t \) } {} and h ( t ) = exp ( bt ) u ( t ) size 12{h \( t \) ="exp" \( - ital "bt" \) u \( t \) } {} with u ( t ) size 12{u \( t \) } {} representing a step function starting at 0 for 0 t 8 size 12{0<= t<= 8} {} . Consider the following values of the approximation pulse width or delta: Δ = 0 . 5, 0 . 1, 0 . 05 , 0 . 01 , 0 . 005 , 0 . 001 size 12{Δ=0 "." 5,`0 "." 1,`0 "." "05",`0 "." "01",`0 "." "005",`0 "." "001"} {} . Mathematically, the convolution of h ( t ) size 12{h \( t \) } {} and x ( t ) size 12{x \( t \) } {} is given by

y ( t ) = 1 a b ( e bt e at ) u ( t ) size 12{y \( t \) = { {1} over {a - b} } \( e rSup { size 8{ - ital "bt"} } - e rSup { size 8{ - ital "at"} } \) u \( t \) } {}

Compare the approximation y ˆ ( ) size 12{ { hat {y}} \( nΔ \) } {} obtained via the function conv with the theoretical value y ( t ) size 12{y \( t \) } {} given by Equation (1). To better see the difference between the approximated y ˆ ( ) size 12{ { hat {y}} \( nΔ \) } {} and the true y ˆ ( ) size 12{ { hat {y}} \( nΔ \) } {} values, display y ˆ ( t ) size 12{ { hat {y}} \( t \) } {} and y ( t ) size 12{y \( t \) } {} in the same graph.

Compute the mean squared error (MSE) between the true and approximated values using the following equation:

MSE = 1 N n = 1 N ( y ( ) y ˆ ( ) ) 2 size 12{ ital "MSE"= { {1} over {N} } Sum cSub { size 8{n=1} } cSup { size 8{N} } { \( y \( nΔ \) - { hat {y}} \( nΔ \) \) rSup { size 8{2} } } } {}

where N = T Δ size 12{N= left lfloor { {T} over {Δ} } right rfloor } {} , T is an adjustable time duration expressed in seconds and the symbol . size 12{ left lfloor "." right rfloor } {} denotes the nearest integer. To begin with, set T = 8 size 12{T=8} {} .

As you can see here, the main program is written as a .m file and placed inside LabVIEW as a LabVIEW MathScript node by invoking Functions Programming Structures MathScript . The .m file can be typed in or copied and pasted into the LabVIEW MathScript node. The inputs to this program consist of an approximation pulse width Δ size 12{Δ} {} , input exponent powers a size 12{a} {} and b size 12{b} {} and a desired time duration T size 12{T} {} . To add these inputs, right-click on the border of the LabVIEW MathScript node and click on the Add Input option as shown in [link] .

(a) Adding Inputs, (b) Creating Controls

After adding these inputs, create controls to allow one to alter the inputs interactively via the front panel. By right-clicking on the border, add the outputs in a similar manner. An important consideration is the selection of the output data type. Set the outputs to consist of MSE, actual or true convolution output y_ac and approximated convolution output y. The first output is a scalar quantity while the other two are one-dimensional vectors. The output data types should be specified by right-clicking on the outputs and selecting the Choose Data Type option (see [link] ).

(a) Adding Outputs, (b) Choosing Data Types

Next write the following .m file textual code inside the LabVIEW MathScript node:

t=0:Delta:8;

Lt=length(t);

x1=exp(-a*t);

x2=exp(-b*t);

y=Delta*conv(x1,x2);

y_ac=1/(a-b)*(exp(-b*t)-exp(-a*t));

MSE=sum((y(1:Lt)-y_ac).^2)/Lt

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, An interactive approach to signals and systems laboratory. OpenStax CNX. Sep 06, 2012 Download for free at http://cnx.org/content/col10667/1.14
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'An interactive approach to signals and systems laboratory' conversation and receive update notifications?

Ask