Textbook+Ch-2+MATLAB+Portion

# Textbook+Ch-2+MATLAB+Portion - 46 SIGNALS AND SIGNAL SPACE...

This preview shows pages 1–9. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 46 SIGNALS AND SIGNAL SPACE Parseval’s Theorem in the Fourier Series A periodic signal g(t) is a power signal, and every term in its Fourier series is also a power signal. The power Pg of g(t) is equal to the power of its Fourier series. Because the Fourier series consists of terms that are mutually orthogonal over one period, the power of the Fourier series is equal to the sum of the powers of its Fourier components. This follows from Parseval’s theorem. Thus, for the exponential Fourier series 00 gm = Do + Z Dnejwo’ nz—oo, n;é0 the power is given by (see Prob. 2.1—7) 00 Pg = Z IDnlz (2.68a) VIZ—00 For a real g(t), |D_,,| = anl. Therefore 00 Pg 2 002 + 2 Z |D,, |2 (2.68b) 1121 Comment: Parseval’s theorem occurs in many different forms, such as in Eqs. (2.57) and Eq. (2.68a). Yet another form is found in the next chapter for nonperiodic signals. Although these forms appear to be different, they all state the same principle: that is, the square of the length of a vector equals the sum of the squares of its orthogonal components. The ﬁrst form [Eq. (2.57)] applies to energy signals, and the second [Eq. (2.68a)] applies to periodic signals represented by the exponential Fourier series. Some Other Examples of Orthogonal Signal Sets The signal representation by Fourier series shows that signals are vectors in every sense. Just as a vector can be represented as a sum of its components in a variety of ways, depending upon the choice of a coordinate system, a signal can be represented as a sum of its components in a variety of ways. Just as we have vector coordinate systems formed by mutually orthogonal vectors (rectangular, cylindrical, spherical, etc.), we also have signal coordinate systems, basis signals, formed by a variety of sets of mutually orthogonal signals. There exist a large number of orthogonal signal sets that can be used as basis signals for generalized Fourier series. Some well—known signal sets are trigonometric (sinusoid) functions, exponential functions, Walsh functions, Bessel functions, Legendre polynomials, Laguerre functions, Jacobi polynomials, Hermite polynomials, and Chebyshev polynomials. The functions that concern us most in this book are the exponential sets discussed next in the chapter. 2.8 MATLAB EXERCISES In this section, we provide some basic MATLAB exercises to illustrate the process of signal generation, signal operations, and Fourier series analysis. 2.8 MATLAB Exercises 47 Basic Signals and Signal Graphing Basic functions can be deﬁned by using MATLAB ’s m-ﬁles. We gave three MATLAB programs that implement three basic functions when a time vector t is provided: - us tep .m implements the unit step function u(t) - rect .m implements the standard rectangular function rect(t) ° triangl .m implements standard triangle function A(t) % (file name: ustep.m) % The unit step function is a function of time ’t’. % Usage y = ustep(t) % % ustep(t) = 0 if t < 0 % ustep(t) = 1, if t >2 1 % t — must be real—valued and can be a vector or a matrix $0 o\° function y=ustep(t) y = (t>=0)7 end __—___________________________.——____—_—-———————-—— _______—__________—__._—__—————-—-—-—————————-—- (file name: rect.m) o\° o\° The rectangular function is a function of time ’t’. Usage y = rect(t) o\° o\° o\° t — must be real—valued and can be a vector or a matrix % % rect(t) = 1, if |t| < 0.5 % rect(t) : 0, if it| > 0.5 % function y=rect(t) y :(sign(t+0.5)—sign(t-O.5) >0); end _________________________________________________________________________ __________________________________________________________________________ % (file name: triangl.m) % The triangle function is a function of time ’t' % % triangl(t) = l-iti, if |t| < 1 triangl(t) = 0, if |t| > 1 ($069490 Usage y : triangl(t) 0‘? t — must be real—valued and can be a vector or a matrix d9 48 SIGNALS AND SIGNAL SPACE Figure 2.19 Graphing o ﬁgnaL y rm time domain 3 _"l l 'l _1 —I I 'l '“l' '—|' 3—4—4 I__I__L_I___| l I —2 —15 —l’ —05 0 05 1 L5 2 25 3 function yztriangl(t) y = (l—abs(t)).*(t>=—l).*(t<l); end -——————-—————.___________——______ We now show how to use MATLAB to generate a simple signal plot through an example. siggraf . m is provided. In this example, we construct and plot a signal ya) = exp (4;) sin (67mm + 1) The resulting graph shown in Fig. 2.19. —~—————_____—____________ % (file name: siggraf.m) % To graph a signal, the first step is to determine % the x—axis and the y—axis to plot % we can first decide the length of x—axis to plot t=[—2:0.0l:3]; % "t" is from —2 to 3 in 0.01 increment % Then evaluate the signal over the range of "t" to plot y=exp(—t).*sin(10*pi*t).*ustep(t+l); figure(l); fig1=p10t(t,y); set(figl,’Linewidth’,2); % choose a wider line—width xlabel(’\it t’); % use italic"t’ to label X—axis ylabel(’\{\bf Y\}(\{\it t})’); % plot t vs y in figure 1 % use boldface ’y’ to label y—axis title(’\{\bf Y\}\_\{\rm time domain\}'); % can use subscript ———————————__—______—_—— Periodic Signals and Signal Power Periodic signals can be generated by ﬁrst determining the signal values in one period before repeating the same signal vector multiple times. In the following MATLAB program PfuncEx.m, we generate a periodic signal and observe its behavior over 2M periods. The period of this example is T = 6. The program also evaluates the average signal power which is stored as a variable y _power and signal energy in one period which is stored in variable y_energyT. 2.8 MATLAB Exercises 49 % (file name: PfuncEX.m) % This example generates a periodic signal, plots the signal % and evaluates the average signal power in y_power and signal % energy in 1 period T: y_energyT echo off;clear;clf; To generate a periodic signal g‘T(t), % we can first decide the signal within the period of ’T’ for g(t) o\o Dt=0.002; % r1ime interval (to sample the signal) T=6; '% period=T M23; % r"o generate 2M periods of the signal t=[O:Dt:T—Dt]; %"t" goes for one period [0, T] in Dt increment Then evaluate the signal over the range of "T" y=eXp(—abs(t)/2).*sin(2*pi*t).*(ustep(t)—ustep(t—4)); Multiple periods can now be generated. 6p 0‘9 time=; y_periodic=; for i=—M:M—l, time=[time i*T+t]; y_periodic=[yrperiodic y]; end figure(l); fy=plot(time,y_periodic); set(fy,’Linewidth’,2);xlabel(’{\it t}’); echo on Compute average power y_power=sum(y_periodic*y_periodic’)*Dt/(max(time)—min(time)) o\o o\° Compute signal energy in 1 period T y_energyT=sum(y.*conj(y))*Dt The program generates a periodic signal as shown in Fig. 2.20 and numerical answers: y_power = 0.0813 y_energyT = 0.4878 Signal Correlation The MATLAB program can implement directly the concept of signal correlation introduced in Section 2.5. In the next computer example, we provide a program, sign_cor .m, that evaluates the signal correlation coefﬁcients between x(t) and signals g1(t), g2(t), . . . g5 (t). The program ﬁrst generates Fig. 2.21, which illustrates the six signals in the time domain. % (file name: sign_cor.m) clear To generate 6 signals x(t), g_l(t), ... g_5(t); do % of this Example % we can first decide the signal within the period of ’T’ ﬁbr g(t) 50 SIGNALS AND SIGNAL SPACE Figure 2.20 1 ~ . . . . ,_ .1— _, (Seneraﬁng a periodic signal. 08 r 1 Q6- _ Q4— : _ 0.2 — J 0L 1 —02- — r04— _ —0.6 L 4 0.8 ' ' J— L. .__| I , A20 —-15 —10 —5 0 5 10 15 20 Figure 2.21 Sxﬂmpb sgndx 810) Dt=0.0l; % time increment Dt T=6.0; % time duration 2 T t=[—l:Dt:T]; %"t" goes between [—1, T] in Dt increment o 6 Then evaluate the signal over the range of "t" to plot x:ustep(t)—ustep(t—5); gl=0.5*(ustep(t)—ustep(t—5)); g2=—(ustep(t)—ustep(t—5)); g3=exp(—t/5).*(ustep(t)—ustep(t—5)); g4=exp(—t).*(ustep(t)—ustep(t—5)); g5=sin(2*pi*t).*(ustep(t)—ustep(t—5)); 2.8 MATLAB Exercises 51 subplot(23l); sigl=plot(t,x,’k’); xlabel(’\it t’); ylabel(’{\it X}({\it t})’); % Label axis set(sigl,’Linewidth’,2); % change linewidth axis([—.5 6 —l.2 l.2]); grid % set plot range subplot(232); sig2=plot(t,gl,’k’); Xlabel(’\it t’); Ylabel(’{\it g}_l({\it t})’); set(sig2,’Linewidth’,2); axis([—.5 6 -1.2 l.2]); grid subplot(233); sig3=plot(t,g2,’k’); Xlabel(’\it t’); Yiabel(’{\it g}_2({\it t})’); set(sig3,’Linewidth’,2); axis([—.5 6 —l.2 l.2]); grid subplot(234); sig4=piot(t,g3,’k'); Xlabel(’\it t’); ylabel(’{\it g}_3({\it t})’); set(sig4,’Linewidth’,2); axis([—.5 6 —l.2 1.2 ); grid subplot(235); sig5=piot(t,g4,’k’); Xlabel(’\it t’); ylabel(’{\it g}_4({\it t})’); set(sig5,’Linewidth’,2);grid aXiS([—.5 6 —l.2 1.2.); subplot(236); sig6zp;0t(t,g5,’k’); xlabel(’\it t’); Ylabel(’{\it g}_5({\it t})’); set(sig6,’Linewidth’,2);grid axis([—.5 6 —l.2 1.2 ); % Computing signal energies EO=sum(X.*conj(x))*Dt; El:sum(g1.*conj(gl )*Dt; E2=sum(g2.*conj( ) E3=sum(g3.*conj( ) E4=sum(g4.*conj(g4))*3t; E5=sum(g5.*conj( ) .*conj(x) *Dt/(sqrt(EO*EO)) clzsum .*conj(g1 )*Dt/(sqrt(EO*El)) c2=sum )*Dt/(sqrt(EO*E2)) C3=sum .*conj(g3 )*Dt/(sqrt(EO*E3)) .*conj(g4 )*Dt/(sqrt(EO*E4) x x x.*conj(g2 X x x )*Dt/(sqrt(EO*E5) ) ) ) ) ) ) .*conj(95) ) The six correlation coefﬁcients are obtained from the program as C0: 1 cl = 1 c2 = 52 SIGNALS AND SIGNAL SPACE c3 = 0.9614 c4 = 0.6282 c5 = 8.6748e—17 Numerical Computation of Coefﬁcients 0,, There are several ways to numerically compute the Fourier series coefﬁcients D". We will use MATLAB to show how to use numerical integration in the evaluation of Fourier series. To carry out a direct numerical integration of Eq. (2.60), the ﬁrst step is to deﬁne the symbolic expression of the signal g(t) under analysis. We use the triangle function A(t) in the following example. 0‘9 (funct_tri.m) o\° A standard triangle function of base —1 to 1 function y = funct_tri(t) Usage y = func_tri(t) o\0 % t 2 input variable i Y=((t>—l)—(t>l)).*(l—abs(t)); Once the ﬁle funct_tri .m deﬁnes the function y 2 g(t), we can directly carry out the necessary integration of Eq. (2.60) for a ﬁnite number of Fourier series coefﬁcients {Dm n = —N, . . . , —1, O, 1, .. . , N}. We provide the following MATLAB program called FSexample . m to evaluate the Fourier series of A(t/2) with period [a, b] (a = —2, b = 2). In this example, N = 11 is selected. Executing this short program in MATLAB will generate Fig. 2.22 with both amplitude and angle of D”. % (file name: FSexp_a.m) % This example shows how to numerically evaluate % the exponential Fourier series coefficients Dn % directly. % The user needs to define a symbolic function % g(t). In this example, g(t)=funct_tri(t). echo off; clear; clf; ‘ j=sqrt(—l); % Define j for complex algebra b:2; a=-2; % Determine one signal period tol=l.e—5; % Set integration error tolerance T=b—a; % length of the period N:1l; % Number of FS coefficients % on each side of zero frequency Fi=[—N:N]*2*pi/T; % Set frequency range Figure 2.22 Exponenﬁol Fouﬁerseﬂes coefficients of a repeaied A(t/2) with period T=4. 2.8 MATLAB Exercises Amplitude of D" 0.9 ‘_‘——r‘ I x 0.7 - 06— ID"! 0.4 — Angle of D" 53 95 now calculate D_O and store it in D(N+l); Func= @(t) funct_tri(t/2); D(N+l)=1/T*quad(Func,a,b,tol); % Using quad.m integration for i=l:N % Calculate Dn for n=l, . ..,N (stored in D(N+2) D(2N+l) Func= @(t) exp(—j*2*pi*t*i/T).*funct_tri(t/2); D(i+N+1)=quad(Func,a,b,tol); % Calculate Dn for n=—N,...,~l (stored in D(l) D(N) Func= @(t) exp(j*2*pi*t*(N+l—i)/T).*func_tri(t/2); D(i): quad(Func,a,b,tol); end figure(l); subplot(21l);sl=stem([—N:N],abs(D)); set(sl,’Linewidth’,2); ylabel(’|{\it D}_{\it n}[’); 54 SIGNALS AND SIGNAL SPACE title(’Amplitude of {\it D}_{\it r1}’) subplot(212) ;52=stem( [—NzN] ,angle(D) ); set(32, ’Linewidth’ ,2); ylabel(’<{\it D}__{\it n} ’); title(’Ang1e of {\it D}_{\it n}’); REFERENCES 1. P. L. Walker, The Theory of Fourier Series and Integrals, Wiley-Interscience, New York, 1986. 2. R. V. Churchill, and J. W. Brown, Fourier Series and Boundary Value Problems, 3rd ed., McGraw- PROBLEMS 2.1-1 Figure P.2.I -l 2.1-2 2.1-3 2.1-4 2.1-5 2.1-6 Hill, New York, 1978. Find the energies of the signals shown in Fig. P2.l—l. Comment on the effect on energy of sign change, time shift, or doubling of the signal. What is the effect on the energy if the signal is multiplied by k? sin I (a) Find Ex and Ey, the energies of the signals x(t) and y(t) shown in Fig. P2.l—2a. Sketch the signals x(t) + y(t) and x(t) — y(t) and show that the energy of either of these two signals is equal to Ex + Ey. Repeat the procedure for signal pair in Fig. P2.l—2b. (b) Now repeat the procedure for signal pair in Fig. P2.l—2c. Are the energies of the signals x(t) + y(t) and x(t) — y(t) identical in this case? Find the power of a sinusoid C cos (wot + 6). Show that if w] 2 (oz, the power of g(t) = C1 cos(w1t + 61) + C2 cos(w2t + 62) is [C12 + C22 + 201 C2 cos(01 — 62)]/2, which is not equal to (C12 + C22)/2. Find the power of the periodic signal g(t) shown in Fig. P2. 1-5‘ Find also the powers and the rms values of (a) —g(t) (b) 2g (t) (c) cg (1). Comment. Find the power and the rms value for the signals in (a) Fig. P2—l-6a; (b) Fig. 2.16; (c) Fig. P2- 1 —6b; ((1) Fig. P2.7—4a; (e) Fig. P2.7-4c. ...
View Full Document

## This note was uploaded on 03/11/2012 for the course EE EE380 taught by Professor Z.u during the Spring '11 term at Lahore University of Management Sciences.

### Page1 / 9

Textbook+Ch-2+MATLAB+Portion - 46 SIGNALS AND SIGNAL SPACE...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online