1 Escola Federal de Egeharia de Itajubá Departameto de Egeharia Mecâica Pós-Graduação em Egeharia Mecâica MPF04 ANÁLISE DE SINAIS E AQUISÇÃO DE DADOS SINAIS E SISTEMAS Trabalho 02 (MATLAB) Prof. Dr. José Juliao de Lima Jr. home page:www.iem.efei.br/juliao Setembro de 2001
2 MPF04 Aálise de Siais e Aquisção de Dados 2/14 Ídice 1.1 Itroductio Project 1: Basic Sigals Exercise: Basic Sigals - Impulses Exercise: Basic Sigals Siusoids Exercise: Sampled Siusoids Exercise: Basic Sigals-Expoetials Project 2: Complex-Valued Sigals Exercise: Complex Expoetials 12
3 Itroductio 3/14 Trabalho 02 SINAIS E SISTEMAS 1.1 Itroductio The basic sigals used ofte i digital sigal processig are the uit impulse sigal δ [, expoetials of the form u[, sie waves, ad their geeralizatio to complex expoetials. The followig projects are directed at the geeratio ad represetatio of these sigals i MATLAB. Sice the oly umerical data type i MATLAB is the M x N matrix, sigal must be represeted as vectors: either M x 1 matrices if colum vectors, or 1 x N matrices if row vectors. I MATLAB all sigals must be fiite i legth. This cotrasts sharply with aalytical problem solvig, where a mathematical formula ca be used to represet a ifiite-legth sigal (e. g., a decayig expoetial, a u[ ). a A Secod issue is the idexig domai associated with a sigal vector. MATLAB assumes by default that a vector is idexed from 1 to N, the vector legth. I cotrast, a sigal vector is ofte the result of samplig a sigal over some domai where the idexig rus from 0 to N-1; or, perhaps, the samplig start at some arbitrary idex that is egative, e. g., at N. The iformatio about the samplig domai caot be attached to the sigal vector cotaiig the sigal values. Istead, the user is forced to keep track of this iformatio separately. Usually, this is ot a problem util it comes time to plot the sigal, i which case the horizotal axis must be labeled properly.
4 MPF04 Aálise de Siais e Aquisção de Dados 4/14 A fial poit is the use of MATLAB's vector otatio to geerate sigals. A sigificat power of the MATLAB eviromet is its high-level otatio for vector maipulatio; for loops are almost always uecessary. Whe creatig sigals such as a sie wave, it is best to apply the si fuctio to a vector argumet, cosistig of all the time samples. I the followig projects, we treat the commo sigals ecoutered i digital sigal processig: impulses, impulse trais, expoetials, ad siusoids. 1.2 Project 1: Basic Sigals This project cocetrates o the issues ivolved with geeratio of some basic discrete-time sigals i MATLAB. Much of the work ceters o usig iteral MATLAB vector routies for sigal geeratio. I additio, a sample MATLAB fuctio will be implemeted. Hits Plottig discrete-time sigals is doe with the stem fuctio i MATLAB. The followig MATLAB code will create 31 poits of a discrete-time siusoid. = 0:30; % vector of time idices sius = si(/2+1); Notice that the = 0 idex must be referred to as (1), due to MATLAB's idexig scheme; likewise, sius(1) is the first value i the siusoid. Whe plottig the sie wave we would use the stem fuctio, which produces the discrete-time sigal plot commoly see i DSP books (see Figura 1.1): stem(,sius ); The first vector argumet must be give i order to get the correct -axis For compariso, try stem(sius) to see the default labelig.
5 Project 1: Basic Sigals 5/14 1 sie wave Time idex () Figura 1.1 -Pottig a discrete-time sigal with stem Exercise: Basic Sigals - Impulses The simplest sigal is the (shifted) uit impulse sigal: 1, = 0 δ[ 0] = (1.1) 0, 0. To create a impulse i MATLAB, we must decide how much of the sigal is of iterest. If the impulse δ [ is goig to be used to drive a causal LTI system, we might wat to see the L poits from = 0 to =L-1. If we choose L = 31, the followig MATLAB code will create a "impulse": L = 31; = 0:(L-1); imp = zeros(l,1); imp(1)=1; Notice that the = 0 idex must be referred to as imp(1), due to MATLAB's idexig scheme. (a). Geerate ad plot the followig sequeces. I each case the horizotal () axis should exted oly over the rage idicated ad should be labeled accordigly. Each sequece should be displayed as a discrete-time sigal usig stem
6 MPF04 Aálise de Siais e Aquisção de Dados 6/14 x [ = 0.9δ[ 5], 1 20, 1 x [ = 0.8δ[, 15 15, 2 x [ = 1.5δ[ 333], , 3 x [ = 4.5δ[ + 7], (b) The shifted impulse, δ ], ca be used to build a weighted [ 0 impulse trai, with period P ad total legth MP: s[ = M 1 l= 0 Alδ[ l P]. (1.2) The weights are AL; if they are all the same. The impulse trai is periodic with period P. Geerate ad plot a periodic impulse trai whose period is P = 5 ad whose legth is 50. Start the sigal at =0. Try to use oe or two vector operatios rather tha a for loop to set the impulse locatios. How may impulses are cotaied withi the fiitelegth sigal? (c). The followig MATLAB code will produce a repetitive sigal i the vector x. x=[0;1;1;0;0;0]*oes(1,7); x=x(:); size(x) % retur the sigal legth Plot x to visualize its form; the give a mathematical formula similar to equatio (1.2) to describe this sigal Exercise: Basic Sigals Siusoids Aother very basic sigal is cosie wave. I geeral, it takes three parameters to describe a real siusoidal sigal completely: amplitude (A), frequecy (Ω0), ad phase (φ). x [ = Acos( Ω0 + φ) (1.3)
7 Project 1: Basic Sigals 7/14 (a). Geerate ad plot each of the followig sequeces. Use MATLAB's vector capability to do this with oe fuctio call by takig the cosie (or sie) of a vector argumet. I each case, the horizotal () axis should exted oly over the rage idicated ad should be labeled accordigly. Each sequece should be displayed as a sequece usig stem. π x1[ = si( ), , π x2[ = si( ), , π x3[ = si(3π + ), , x4[ = cos( π ), Give a simpler formula for x3[ that does ot use trigoometric fuctios. Explai why x4[ is a ot periodic sequece. (b). Write a MATLAB fuctio that will geerate a fiite-legth siusoid. The fuctio will eed a total of five iput argumets: three for the parameters ad two more to specify the first ad last idex of the fiite-legth sigal. The fuctio should retur the result a colum vector that cotais the values of the siusoid. Test this fuctio by plottig the results for various choices of the iput parameters. I particular, show how to geerate the sigal 2si( π /11) for (c). Modificatio: Rewrite the fuctio i part (b) to retur two argumets: a vector of idices over the rager of, ad the values of the sigal Exercise: Sampled Siusoids Ofte a discrete-time sigal is produced by samplig a cotiuous-time sigal such as a costat-frequecy sie wave. The relatioship betwee the cotiuos-time frequecy ad the samplig frequecy is mai poit of
8 MPF04 Aálise de Siais e Aquisção de Dados 8/14 Nyquist-Shao samplig theorem, which requires that samplig frequecy be at least twice the highest frequecy i the sigal for perfect recostructio. I geeral, a cotiuos-time siusoid is give by the followig mathematical formula: s ( t) = Acos(2πf0t + φ) (1.4) where A is the amplitude f0 is the frequecy i Hertz, ad φ is the iitial phase. If a discrete-time sigal is produced by regular samplig of s(t) at a rate of fs=1/t, we get f 0 s[ = s( t) = Acos(2πf T + φ = A π + φ t= T 0 s ) cos 2 (1.5) f s Compariso with formula (1.4) for a discrete-time siusoid, x[=acos(ω0+φ), shows that the ormalized radia frequecy is ow a scaled versio of f0, Ω0=2π(f0Ts). (a). From formula (1.3) for the cotiuous-time siusoid, write a fuctio that will geerate samples of s(t) to create a fiite-legth discrete-time sigal. This fuctio will require six iputs: three for the sigal parameters, two for the start ad stop times, ad oe for samplig rate (i Hertz). It ca call the previously writte MATLAB fuctio for the discrete-time siusoid. To make the MATLAB fuctio correspod to the cotiuous-time sigal defiitio, make the uits of the start ad stop times secods ot idex umber. Use this fuctio to geerate a sample siusoid with the followig defiitio: Sigal freq= 1200 Hz Samplig freq = 8 KHz Iitial Phase= 45 deg Startig Time= 0 s Amplitude = 50 Edig Time = 7 ms
9 Project 1: Basic Sigals 9/14 Make two plots of the resultig sigal: oe as a fuctio of time t (i millisecod), ad the other as a fuctio of the sample idex used i t=ts. Determie the legth of the resultig discrete-time sigal ad the umber of periods of the siusoid icluded i the vector. (b). Show by mathematical maipulatio that samplig a cosie at the times t = +3/4 T will result i a discrete-time sigal that appears to be a sie wave whe f0 = 1/T. Use the fuctio from part (a) to geerate a discrete-time sie wave by chagig the start ad stop times for the samplig Exercise: Basic Sigals-Expoetials The decayig expoetial is a basic sigal i DSP because it occurs as the solutio to liear costat-coefficiet differece equatios. (a). Study the followig MATLAB fuctio to see how it geerates a discrete-time expoetial sigal. The use the fuctio to plot the expoetial x [ = (0.9) over the rage = 0,1, 2,..., 20. fuctio y = geexp(b,0,l) %GENEXP geerate a expoetial sigal: b^ % usage: y = geexp(b,0,l) % b iput scalar givig ratio betwee terms % 0 startig idex (iteger) % L legth of geerated sigal % y output sigal y(1:l) if(l<= 0) error('genexp: legth ot positive') ed =0+[1:L]'-1; %---vector of idices y=b.^; ed (b). I may derivatios,the expoetial sequece a u[ must be summed over a fiite rage. This sum is kow i closed form: L 1 = 0 a L 1 a = 1 a, for a 1 (1.6)
10 MPF04 Aálise de Siais e Aquisção de Dados 10/14 Use the fuctio from part (a) to geerate a expoetial ad the sum it up; compare the result to formula (1.6). (c). Oe reaso the expoetial sequece occurs so ofte i DSP is that time shiftig does ot chage the character of the sigal. Show that the fiite-legth expoetial sigal satisfies the shiftig relatio: y[ = ay[ 1] over the rage1 L 1 (1.7) By comparig the vectors y(2 :L) ad a *y(1:l-1). Whe shiftig fiitelegth sigals i MATLAB, we must be careful at the edpoits because there is o automatic zero paddig. (d). Aother way to geerate a expoetial sigal is to use a recursive formula give by a differece equatio. The sigal y[=a u[ is the solutio to the followig differece equatio whe the iput, x[, is a impulse: y[ ay[ 1] = x[ iitial coditio : y[ 1] = 0 (1.8) Sice the differece equatio is assumed to recurse i a causal maer (i. e., for icreasig ), the iitial coditios at =-1 is ecessary. I MATLAB the fuctio filter will implemet a differece equatio. Use filter to geerate the same sigal as i part (a) (i. e., a = 0.9). 1.3 Project 2: Complex-Valued Sigals This project ceters o the issues ivolved with represetig ad geeratig complex-valued sigals. Although i the real world, sigals must have real values, it is ofte extremely useful to geerate, process, ad iterpret real-valued sigal pairs as complex-valued sigals. This is doe by combiig the sigals ito a pair, as the real ad imagiary parts of a complex umber, ad processig this pair with other complex-valued sigals
11 Project 2: Complex-Valued Sigals 11/14 usig the rules of complex arithmetic. Use of sigal pairs i this way is a importat part of may sigal processig systems, especially those ivolvig modulatio. Complex expoetials are a class of complex sigals that is extremely importat because the complex amplitude (phasor otatio) provides a cocise way to describe siusoidal sigals. Most electrical egieerig studets are familiar with phasors i coectio with ac circuits or power systems, but their use i radar, wave propagatio, ad Fourier aalysis is just as sigificat (although the term phasor is ot always used). Hits I MATLAB, the fuctios real ad imag will extract the real ad imagiary parts of a complex umber. Whe plottig a complex vector, the defaults for plot ad stem ca be cofusig. If z is complex, the plot(z) will plot the imagiary part versus the real part; ad plot(,z) will plot the real part of z versus. However, stem(z) will just plot the real part. If you wat to view simultaeous plots of the real ad imagiary parts, the subplot(211) ad subplot(212) commads prior to each stem commad will force the two plots to be placed o the same scree, oe above the other. See Figura 1.2, which was created usig the followig code: = 0:25; xx = exp(j*/3); %--- complex expoetial subplot (211) stem(,real(xx)) title('real PART'), xlabel('index ()') subplot (212) stem(,imag(xx)) title('imag PART'), xlabel('index ()')
12 MPF04 Aálise de Siais e Aquisção de Dados 12/14 1 REAL PART INDEX () 1 IMAG PART INDEX () Figura Plottig Real ad Imagiary Parts of a Discrete-Time Sigal with subplot Exercise: Complex Expoetials The real expoetial otatio ca be exteded to complex-valued expoetial sigals that embody the sie ad cosie sigals. These sigals form the basis of the Fourier trasform. (a). I MATLAB a complex sigal is a atural extesio of the otatio i Exercise 1.4. Thus the parameters a ca be take as a complex umber to geerate these sigals. Recall Euler's formula for the complex expoetial (i a form that gives a sigal): x[ = ( z 0 ) = e (l Z + j z ) jθ 0 0 = r e = r (cosθ + jsiθ ) (1.9) where zo=re jθ =r θ. Use this relatioship to geerate a complex expoetial with z0= Plot the real ad imagiary parts of x[ over the rage Notice that the agle of z0 cotrols the frequecy of the siusoids. (b). For the sigal i part (a) make a plot of the imagiary part versus the real part. The result should be a spiral. Experimet with differet agles for θ - a smaller value should produce a better picture of a spiral. (c). Equatio (1.9) is ot geeral eough to produce all complex expoetials. What is missig is a complex costat to scale the
13 Project 2: Complex-Valued Sigals 13/14 amplitude ad phase of the siusoids. This is the so-called phasor otatio: jφ jθ j( θ+φ) G. z0 = Ae r e = Ar e = Ar [cos( θ + φ) + jsi( θ + φ)], (1.10) where G = A e jφ = A φ is the complex amplitude of the complex expoetial. Geerate ad plot each of the followig sequeces. Covert the siusoids to complex otatio; the create the sigal vector usig exp. If the sigal is purely real, it should be geerated by takig the real part of a complex sigal. I each plot, the horizotal () axis should exted oly over the rage idicated ad should be labeled accordigly. π π x1[ = 3si( ) + j4cos( ), 0 20, 7 7 π x2[ = si( ), 15 25, 17 π π x3[ = 1.1 si( + ), 0 50, 11 4 π x4[ = 0.9 cos( ), For each sigal, determie the values of amplitude ad phase costats that have to be used i G; also the agle ad magitude of zo. (d). These same complex expoetials ca be geerated by first-order differece equatios (usig filter): y [ = z0 y[ 1] + x[. (1.11) The filter coefficiet, z0=re jθ, is a complex umber. The ratio betwee successive terms i the sequece is easily see to be z0; but the correct amplitude ad phase must be set by choosig a complex amplitude for the impulse which drives the differece equatio (i. e., x[ = Gδ[). Use filter to create the same sigals as i part (c). Verify by plottig both the
14 MPF04 Aálise de Siais e Aquisção de Dados 14/14 real ad imagiary parts of y[ ad comparig to the sigals geerated via exp. (e). I the first-order differece equatio (1.11), let yr[ ad yi[ deote the real ad imagiary parts of y[. Write a pair of real-valued differece equatios expressig yr[ ad yi[ i terms of yr[-1], yi[- 1], x[ ad r, cosθ, ad siθ. (f). Write a MATLAB program to implemet this pair of real equatios, ad use this program to geerate the impulse respose of equatio (1.11) for r = 1/2 ad θ = 0, ad θ = π/4. For these two cases, plot the real part of the impulse resposes obtaied. Compare to the real part of the output from the complex recursio (1.11).
Chapter 8 Desig of Digital Filters Cotets Overview........................................................ 8. Geeral Cosideratios................................................. 8. Desig of FIR Filters..................................................
Real-Time Computig Without Stable States: A New Framework for Neural Computatio Based o Perturbatios Wolfgag aass+, Thomas Natschläger+ & Hery arkram* + Istitute for Theoretical Computer Sciece, Techische
GCE Further Mathematics (660) Further Pure Uit (MFP) Tetbook Versio: 4 MFP Tetbook A-level Further Mathematics 660 Further Pure : Cotets Chapter : Comple umbers 4 Itroductio 5 The geeral comple umber 5
SOME GEOMETRY IN HIGH-DIMENSIONAL SPACES MATH 57A. Itroductio Our geometric ituitio is derived from three-dimesioal space. Three coordiates suffice. May objects of iterest i aalysis, however, require far
The Aals of Statistics 2011, Vol. 39, No. 1, 1 47 DOI: 10.1214/09-AOS776 Istitute of Mathematical Statistics, 2011 SUPPORT UNION RECOVERY IN HIGH-DIMENSIONAL MULTIVARIATE REGRESSION 1 BY GUILLAUME OBOZINSKI,
EMWMS (Magus ilsso) EMW/FX/DC (Aders Waer) 1(5) FFT, REALIZATIO AD IMPLEMETATIO I FPGA Griffith Uiversity/Ericsso Microwave System AB /1 by Magus ilsso 1 cos(*pi*4.5/16*t)+i*si(*pi*4.5/16*t).8.6.4...4.6.8
Ecoometrica, Vol. 7, No. 1 (Jauary, 22), 223 262 MAXIMUM LIKELIHOODESTIMATION OF DISCRETEL SAMPLED DIFFUSIONS: A CLOSED-FORM APPROXIMATION APPROACH By acie Aït-Sahalia 1 Whe a cotiuous-time diffusio is
Collectio Techique... Cahier techique o. 194 Curret trasformers: how to specify them P. Foti "Cahiers Techiques" is a collectio of documets iteded for egieers ad techicias, people i the idustry who are
THE PROBABLE ERROR OF A MEAN By STUDENT Itroductio Ay experimet may he regarded as formig a idividual of a populatio of experimets which might he performed uder the same coditios. A series of experimets
Joural of Machie Learig Research 14 (2013) 3207-3260 Submitted 9/12; Revised 3/13; Published 11/13 Couterfactual Reasoig ad Learig Systems: The Example of Computatioal Advertisig Léo Bottou Microsoft 1
G r a d e 5 M a t h e M a t i c s Number Grade 5: Number (5.N.1) edurig uderstadigs: the positio of a digit i a umber determies its value. each place value positio is 10 times greater tha the place value
WHICH MEAN DO YOU MEAN? AN EXPOSITION ON MEANS A Thesis Submitted to the Graduate Faculty of the Louisiaa State Uiversity ad Agricultural ad Mechaical College i partial fulfillmet of the requiremets for
57 Mea-Semivariace Optimizatio: A Heuristic Approach Javier Estrada Academics ad practitioers optimize portfolios usig the mea-variace approach far more ofte tha the measemivariace approach, despite the
Dryad: Distributed Data-Parallel Programs from Sequetial uildig locks Michael Isard Microsoft esearch, Silico Valley drew irrell Microsoft esearch, Silico Valley Mihai udiu Microsoft esearch, Silico Valley
Everythig You Always Wated to Kow about Copula Modelig but Were Afraid to Ask Christia Geest ad Ae-Catherie Favre 2 Abstract: This paper presets a itroductio to iferece for copula models, based o rak methods.
19 Aother Look at Differetiability i Quadratic Mea David Pollard 1 ABSTRACT This ote revisits the delightfully subtle itercoectios betwee three ideas: differetiability, i a L 2 sese, of the square-root
9 Data Aalysis 9. Mea, Media, Mode ad Rage I Uit 8, you were lookig at ways of collectig ad represetig data. I this uit, you will go oe step further ad fid out how to calculate statistical quatities which
Reassessig biases ad other ucertaities i sea-surface temperature observatios measured i situ sice 85, part : measuremet ad samplig ucertaities J. J. Keedy, N. A. Rayer, R. O. Smith, D. E. Parker, ad M.
Crowds: Aoymity for Web Trasactios Michael K. Reiter ad Aviel D. Rubi AT&T Labs Research I this paper we itroduce a system called Crowds for protectig users aoymity o the worldwide-web. Crowds, amed for
Joural of Machie Learig Research 9 (2008) 2015-2033 Submitted 1/08; Revised 5/08; Published 9/08 Cosistecy of Radom Forests ad Other Averagig Classifiers Gérard Biau LSTA & LPMA Uiversité Pierre et Marie
ESAIM: Probability ad Statistics URL: http://wwwemathfr/ps/ Will be set by the publisher THEORY OF CLASSIFICATION: A SURVEY OF SOME RECENT ADVANCES Stéphae Bouchero 1, Olivier Bousquet 2 ad Gábor Lugosi
A Direct Approach to Iferece i Noparametric ad Semiparametric Quatile Models Yaqi Fa ad Ruixua Liu Uiversity of Washigto, Seattle Workig Paper o. 40 Ceter for Statistics ad the Social Scieces Uiversity
Software Reliability via Ru-Time Result-Checkig Hal Wasserma Uiversity of Califoria, Berkeley ad Mauel Blum City Uiversity of Hog Kog ad Uiversity of Califoria, Berkeley We review the eld of result-checkig,
Spectra of radom graphs with give expected degrees Fa Chug, Liyua Lu, ad Va Vu Departmet of Mathematics, Uiversity of Califoria at Sa Diego, La Jolla, CA 92093-02 Edited by Richard V. Kadiso, Uiversity
Noisy mea field stochastic games with etwork applicatios Hamidou Tembie LSS, CNRS-Supélec-Uiv. Paris Sud, Frace Email: firstname.lastname@example.org Pedro Vilaova AMCS, KAUST, Saudi Arabia E-mail:email@example.com