8
Analysis of Signals and Systems Scilab Homework #7 Multiplication, Convolution and Parseval’s Relation with the Fourier Series Dr. David Antonio-Torres Tecnologico de Monterrey at Puebla School of Engineering and Information Technology Departament of Electronics and Physics

Practice 7

Embed Size (px)

DESCRIPTION

knjknjknjk

Citation preview

  • Analysis of Signals and SystemsScilab Homework #7

    Multiplication, Convolution and ParsevalsRelation with the Fourier Series

    Dr. David Antonio-TorresTecnologico de Monterrey at Puebla

    School of Engineering and Information Technology

    Departament of Electronics and Physics

  • Multiplication, Convolutionand Parsevals Relation withthe Fourier Series

    Objectives

    The student will implement the properties of multiplication, convolution andthe parsevals relation of the Fourier series with Scilab.

    Introduction

    The previous Scilab homework introduced the Scilab-code implementationof four properties: linearity, time shifting, time reversal and time differenti-ation. Using the coefficients of the Fourier series of simple periodic signals,the coefficients of more elaborate periodic signals can be derived. Indeed,using the simple signal as a basic building block to construct the elaboratesignal, the coefficients of the latter can be calculated, without explicitly usingthe analysis equation of the Fourier series. Another three properties of theFourier series that are not used for building elaborate signals, but representsignal processing of their own are multiplication, convolution and Parsevalsrelation.

    In this homework, the three properties will be implemented in Scilabcode and, for the multiplication and convolution, the synthesized signal willbe plotted for verification purposes. As for Parsevals relation, this propertyreturns the power of the signal calculated with the coefficients of the Fourierseries.

    1

  • Multiplication

    The property of multiplication indicates that when two periodic signals withthe same period are multiplied in the time domain, that is, z(t) = x(t)y(t),their coefficients are convolved in the frequency domain. Equation 1 expressesthis property.

    z(t) = x(t)y(t)FS Z[k] = X[k] Y [k] =

    q=

    X[q]Y [k q] (1)

    Convolution

    The property of convolution indicates that when two signals are convolvedin the time domain, that is z(t) = x(t) y(t), their coefficients multiply inthe frequency domain. Equation 2 expresses this property. As x(t) and y(t)are both periodic with the same period, the convolution between the two iscalled periodic convolution.

    z(t) = x(t) y(t) FS TX[k]Y [k] (2)

    Parsevals relation

    The Parsevals relation indicates that the power of a periodic signal can becalculated by adding the square of the absolute value of all the coefficientsof the signal. Equation 3 expresses this property.

    P =

    k=

    |X[k]|2 (3)

    In the following section, the implementation code for the three propertiesdiscussed above will be explained.

    Antecedents

    As can be seen from the definitions of the properties above, the properties relyon the existence of the coefficients of the Fourier series; for this reason, theimplementation of the properties start with the calculation of the coefficients,

    2

  • the property is applied to the coefficients and, finally, the resulting signal issynthesized. The treatment for Parsevals relation is a bit different, as thisproperty calculates the power of the signal; in this case, the built-in functiondisp will be used in the script file to print in the console the power of thesignal.

    Figure 1 shows the periodic signal x(t), while Figure 2 shows the periodicsignal y(t). These two signals will be used for the implementation of theproperties below.

    Figure 1: Periodic signal that will play the role as signal x(t) with period 5

    Multiplication

    In the frequency domain, the multiplication requires the discrete convolu-tion between the coefficients of both signals; the convolution is discrete (thecorrect name is the convolution sum) as the coefficients of the signals arediscrete representations of their frequency spectrum. The built-in functionof Scilab to implement the discrete convolution is convol. The order in whichthe coefficients are passed to the function does not affect the result, as theconvol function is commutative.

    The Scilab code below calculates the coefficients of the signals shown inFigure 1 and in Figure 2, computes the convolution sum of the coefficients

    3

  • Figure 2: Periodic signal that will play the role as signal y(t) with period 5

    and synthesizes the resulting signal, which is termed z(t); Figure 3 showsz(t).

    //implementation of the multiplication property

    xk = cfs(5,2+t,-2,-1,100)+cfs(5,1,-1,1,100)+cfs(5,2-t,1,2,100);

    yk = cfs(5, 1, -3, -1, 100) + cfs(5, -t, -1, 1, 100);

    zk = convol(xk,yk);

    t = [-7:0.01:7];

    zt = icfs(5, zk, t);

    plot(t, zt), xtitle(Periodic signal from the multiplication property);

    Convolution

    The property of convolution requires that the coefficients of the signals bemultiplied k-by-k and then multiplied by the period T. The position-by-position multiplication required by the convolution property is implementedin Scilab by the dot-times operator, i.e. .*. The Scilab code below calcu-lates the coefficients of the signals shown in Figure 1 and Figure 2, multipliesthe coefficients and the period and synthesizes the resulting coefficients. Theresulting signal w(t) is shown in Figure 4.

    4

  • Figure 3: Periodic signal z(t) that results from the multiplication of x(t) andy(t)

    //implementation of the convolution property

    T = 5;

    xk = cfs(T,2+t,-2,-1,100)+cfs(T,1,-1,1,100)+cfs(T,2-t,1,2,100);

    yk = cfs(T, 1, -3, -1, 100) + cfs(T, -t, -1, 1, 100);

    wk = T.*xk.*yk;

    t = [-7:0.01:7];

    wt = icfs(5, wk, t);

    plot(t, wt), xtitle(Periodic signal from the convolution property);

    Parsevals relation

    The Parsevals relation indicates that the power of a periodic signal canbe calculated using the coefficients of the Fourier series. As can be seenin Equation 3, the accuracy of the calculated power is dependant of thenumber of coefficients calculated. The Scilab code below calculates the firstone hundred coefficients of the periodic signals shown in Figure 1 and Figure2, calculates the power of the two signals according to Equation 3 and printsthe power in the console of Scilab using the disp function.

    //calculation of the power of a signal

    5

  • Figure 4: Periodic signal w(t) that results from the convolution of x(t) andy(t)

    xk = cfs(5,2+t,-2,-1,100)+cfs(5,1,-1,1,100)+cfs(5,2-t,1,2,100);

    px = abs(xk);

    px = px .^2;

    px = sum(px);

    disp(The power of x(t) is);

    disp(px)

    yk = cfs(5, 1, -3, -1, 100) + cfs(5, -t, -1, 1, 100);

    py = abs(yk);

    py = py .^2;

    py = sum(py);

    disp(The power of y(t) is);

    disp(py)

    As can be seen in the Scilab code above, once the coefficients of theFourier series are calculated with the cfs function, the Parsevals relation isexecuted by three built-in Scilab functions: abs calculates the magnitude ofthe coefficients, squares the magnitude of the coefficients and sum runs thesum of the squares of the magnitudes of the coefficients.

    6

  • Instructions

    Read carefully the instructions below and prepare your report as indicated.In case you have any question, contact the instructor immediately.

    1. Use the signals shown in Figure P3.22 part e and f in the page 256 ofOppenheims textbook Signals and Systems ; these signals will play therole of the periodic signals x(t) and y(t), respectively. Assume bothsignals are periodic with period 6. Create a script file that calculatesthe first one hundred harmonics of each signal, calculates the powerof each signal using the Parsevals relation and prints the value of thepower on the console of Scilab using the disp function.

    2. Create a script file that implements the multiplication operation withthe two signals of the previous step, synthesizes and plots the resultingsignal. Export the plot as a JPG image.

    3. Create a script file that implements the convolution operation with thetwo signals of the first step, synthesizes and plots the resulting signal.Export the plot as a JPG image.

    4. Create a single ZIP file that contains all the .sce files and the images.

    5. Upload your ZIP in Blackboard using the link provided for this purpose.

    7