<< 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.
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
to compute numerical approximations to the convolution integral.
In this example, use the function conv to compute the convolution of the signals and with representing a step function starting at 0 for . Consider the following values of the approximation pulse width or delta: . Mathematically, the convolution of and is given by
Compare the approximation
obtained via the function
conv
with the theoretical value
given by Equation (1). To better see the difference between the approximated
and the true
values, display
and
in the same graph.
Compute the mean squared error (MSE) between the true and approximated values using the following equation:
where , T is an adjustable time duration expressed in seconds and the symbol denotes the nearest integer. To begin with, set .
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 , input exponent powers and and a desired time duration . 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] .
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] ).
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
Notification Switch
Would you like to follow the 'An interactive approach to signals and systems laboratory' conversation and receive update notifications?