1. Trang chủ >
2. Công Nghệ Thông Tin >
3. Kỹ thuật lập trình >

# 8 Discrete Fourier Transforms and Correlation: Fourier[], InverseFourier[], and ListCorrelate[]

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (4.66 MB, 453 trang )

An Engineer’s Guide to Mathematica®

190

is found that gn = fn /Δt. These relationships are valid when f(t) = 0 for t < 0. Furthermore,

it can be shown that the Fn are symmetrical about M/2. Therefore, when Gn is displayed as

the amplitude in a frequency band Δf centered at nΔf, it is displayed as |Gn | = 2ΔtΔf|Fn | =

2|Fn |/M, where n = 1, 2, … , M/2.

In this notation, it can be shown that the total energy in the signal using the time domain

samples is

E = Δt

M

fn2

(5.3)

n=1

This value is equal to the total power density obtained from the transformed quantities, which

is given by

E=

M∕2

2Δt ∑ | |2

F

M n=1 | n |

(5.4)

Consequently, the power density Pn in the frequency band centered at nΔf is

Pn =

2Δt | |2

F

M | n|

n = 1, 2, ..., M∕2

The numerical implementations of Eqs. (5.1) and (5.2), respectively, are

Fn=Fourier[fn,FourierParameters->{a,b}]

and

fn=InverseFourier[Fn,FourierParameters->{a,b}]

In signal processing, auto- and cross-correlation on lists of signal amplitudes can be determined with

r12=Listcorrelate[list1,list2,{kL,kR}]

where list1 and list2 are lists of the same length and for signal processing kL = 1

and kR = 1 is adequate. When list1 = list2, we have autocorrelation; that is, r11.

Frequently, r12 is normalized as r12/(r11[] r22[])1/2 and r11 is normalized

as r11/r11[], where the index 1 indicates the autocorrelation function at t = 0.

We now illustrate the use of these commands. Additional applications are given in Examples

10.3 and 10.4.

Numerical Evaluations of Equations

191

Example 5.27

Spectral Analysis of a Sine Wave

We shall examine the sampling of m periods of a sine wave of frequency fo and a maximum

magnitude of 2.5; that is,

fn = f (nΔt) = 2.5 sin(2𝜋fo nΔt)

1 ≤ n ≤ 𝛼m

where 𝛼 is the number of samples per period. Hence, is it seen that Δt = 1/(𝛼fo ) (since fh =

fo ) and M = m𝛼. It is assumed that fo = 10 Hz, 𝛼 = 50 and m = 4. We shall display the values

of the sampled signal, plot the magnitude of the components of the frequency spectrum given

by |Gn |, and take the inverse Fourier transform to recover the original signal. In addition, we

shall compute the total energy in the waveform using Eqs. (5.3) and (5.4).

In the program that follows, datp, datf, and ifdt are the coordinate pairs that are

placed in a format required by ListPlot and ListLinePlot. In addition, dat are the

values of the sampled waveform, ft are the complex values of the Fourier transform of the

sampled values, and ift are the values of the inverse of ft. In plotting |Gn |, only the first 20

data values are used. The option Filling is used to connect the data values with a straight

line that ends on the x-axis; this option is illustrated in Table 6.15. The results are shown in

Figure 5.20.

f(t)

|Gn|

2.5

2

2.0

1

1.5

0.1

0.2

0.3

0.4

t

1.0

–1

0.5

–2

10

20

30

(a)

40

f (Hz)

(b)

f(t)

2

1

0.1

0.2

0.3

0.4

t

–1

–2

(c)

Figure 5.20 (a) Sampled waveform, (b) spectral plot of the sampled waveform, and (c) inverse Fourier

transform

192

An Engineer’s Guide to Mathematica®

m=4.0; α=50.0; nn=m α; fo =10.0; dt=1/(α fo );

dat=Table[2.5 Sin[2 π fo n dt],{n,nn}];

datp=Table[{k dt,dat[[k]]},{k,1,nn}];

ListPlot[datp,AxesLabel->{"t","f(t)"}]

ft=Fourier[dat,FourierParameters->{1,-1}];

datf=Table[{(k-1)/(nn dt),2. Abs[ft[[k]]]/(m α)},

{k,1,nn/2-1}];

ListPlot[datf[[1;;20]],PlotRange->All,Filling->Axis,

AxesLabel->{"f (Hz)","|Gn |"}]

ift=InverseFourier[ft,FourierParameters->{1,-1}];

ifdt=Table[{k dt,ift[[k]]},{k,1,nn}];

ListLinePlot[ifdt,AxesLabel->{"t","f(t)"}]

daf2=Table[Abs[ft[[k]]]ˆ2,{k,1,nn/2-1}];

Print["E from time data = ",dt Total[datˆ2]]

Print["E from transformed data = ",2 dt/nn Total[daf2]]

The following values of the total energy are displayed

E from time data = 1.25

E from transformed data = 1.25

Example 5.28

Spectral Analysis of a Sine Wave of Finite Duration

We again consider the sign wave of Example 5.27, except it is now sampled over a time T =

Km, where K ≥ 1 is an integer and m is the number of periods of the sine wave. We assume

that fo = 10 Hz, 𝛼 = 50, m = 4, and K = 8. It is mentioned that as K increases, the frequency

resolution increases; that is, Δf becomes smaller. We shall obtain a plot of the amplitudes |Gn |

comprising the components of its amplitude spectrum and display them over the range 0 ≤

f ≤ 20 Hz. The maximum number of amplitudes to be plotted is chosen to be the integer value

of 20Km/fo . Thus,

kk=8; m=4.0; α=50.0; nn=kk m α; fo =10.0; dt=1/(α fo );

dat=Table[Piecewise[{{Sin[2 π fo n dt],1<=n<=α m},

{0,α m<=n<=nn}}],{n,nn}];

ft=Fourier[dat,FourierParameters->{1,-1}];

datf=Table[{(k-1)/(nn dt),2. Abs[ft[[k]]]/nn},{k,1,nn/2}];

last=Round[20 kk m/fo ];

ListPlot[datf[[1;;last]],Filling->Axis,

AxesLabel->{"f (Hz)","|Gn |"}]

produces the result shown in Figure 5.21.

Numerical Evaluations of Equations

193

|Gn|

0.12

0.10

0.08

0.06

0.04

0.02

5

10

15

20

f (Hz)

Figure 5.21 Amplitude spectral plot of a 10 Hz sine wave with a duration of four periods that is

sampled over a time interval of thirty-two periods

Example 5.29

Cross-Correlation of a Signal with Noise

We shall obtain the normalized cross-correlation of a sine wave with a sine wave with noise.

The amplitude of the noise will not exceed 20% of the sine wave amplitude. We use a

procedure employed in the previous two examples to generate the sampled waveform and

we use RandomReal to create the noise. The signal with noise is displayed along with the

cross-correlation of the signals. The program that produces Figure 5.22 is as follows.

m=4.0; α=50.0; nn=m α; fo =10.0; dt=1/(α fo );

dat=Table[Sin[2 π fo n dt],{n,nn}];

datn=dat+0.2 RandomReal[{-1,1},nn];

datp=Table[{k dt,datn[[k]]},{k,1,nn}];

ListLinePlot[datp]

datauto=ListCorrelate[dat,dat,{1,1}];

datnauto=ListCorrelate[datn,datn,{1,1}];

datcross=ListCorrelate[dat,datn,{1,1}];

datplot=Table[{k dt,datcross[[k]]/

Sqrt[datauto[] datnauto[]]},{k,1,nn}];

ListLinePlot[datplot]

An Engineer’s Guide to Mathematica®

194

1.0

0.5

0.1

0.2

0.3

0.4

0.3

0.4

–0.5

–1.0

(a)

1.0

0.5

0.1

0.2

–0.5

–1.0

(b)

Figure 5.22 (a) Sine wave with noise and (b) cross correlation of a sine wave with a sine wave with

noise

5.9

Functions Introduced in Chapter 5

The functions introduced in this chapter are listed in Table 5.1.

Numerical Evaluations of Equations

Table 5.1

195

Commands introduced in Chapter 5

Command

Purpose

Break

FindFit

Exit a Do or While command

Finds the numerical values of the parameters appearing in an

expression that will provide the best fit to a set of data

Searches for a numerical approximation to a local maximum of

an expression in a specified region

Searches for a numerical approximation to a local minimum of

an expression in a specified region

Searches for a numerical approximation to a root of an

expression in a specified region

Determines the discrete Fourier transform of a list of numerical

values

Constructs a function that approximates a given set of data

Determines the discrete inverse Fourier transform on a list of

numerical values

Determines the cross-correlation of two lists of numerical

values

Finds the numerical solution to one or a set of ordinary

differential equations or to a set of partial differential

equations with two independent variables

Obtains a numerical approximation to a definite integral or

definite multiple integral

Attempts to obtain a numerical solution to an equation or a

system of equations

Finds the numerical solution to one or a set of ordinary

differential equations or to a partial differential equation with

two independent variables as a function of one or more

parameters

Suppresses the display of any messages generated by the

implementation of a Mathematica function

Generates a pseudorandom real number

FindMaximum

FindMinimum

FindRoot

Fourier

Interpolation

InverseFourier

ListCorreleate

NDSolveValue

NIntegrate

NSolve

ParametricNDSolveValue

Quiet

RandomReal

References

 S. Chatterjee, A. K. Mallik, and A. Ghosh, “On impact dampers for non-linear vibrating systems”, Journal of

Sound and Vibration, 1995, 187(3), pp. 403–420.

 F. C. Moon, “Experiments on chaotic motions of a forced nonlinear oscillator: strange attractors,” ASME Journal

of Applied Mechanics, 1980, 47(3), pp. 638–644.

 Y. Zhu, H. N. O˘guz, and A. Prosperetti, “On the mechanism of air entrainment by liquid jets at a free surface,”

Journal of Fluid Mechanics, 2000, 404, pp. 151–177.

 S. Timoshenko and S. Woinowsky-Krieger, Theory of Plates and Shells, 2nd edn, McGraw Hill, New York,

1959.

 F. P. Incropera and D. P. Dewitt, Introduction to Heat Transfer, 4th edn, John Wiley & Sons, New York, 2002.

 T. Dahlberg, “Procedure to calculate deflections of curved beams,” Journal of Engineering Education, 2004,

20(3), pp. 503–513.

 S. Kosti´c, I. Franovi´c, K. Todorovi´c, and N. Vasovi´c, “Friction memory effect in complex dynamics of earthquake

model”, Nonlinear Dynamics, 2013, 73(3), pp. 1933–1943.

An Engineer’s Guide to Mathematica®

196

 B. S. Shvartsman, “Analysis of large deflections of a curved cantilever subjected to a tip-concentrated follower

force,” International Journal Nonlinear Mechanics, 2013, 50, pp. 75–80.

 A. Belendez, A. Hernandez, T. Belendez, M. L. Alvarez, S. Gallego, M. Ortuno, and C. Neipp, “Application

of the harmonic balance method to a nonlinear oscillator typified by a mass attached to a stretched string,”,

J. Sound Vibration, 2007, 302, pp. 1018–1029.

 A. S. dePaula, M. A. Savi, and F. H. I. Pereira-Pinto, “Chaos and transient chaos in an experimental nonlinear

pendulum,” Journal of Sound and Vibration, 2006, 295, pp. 585–595.

 Y. Starosvetsky and O.V. Gendelman, “Interactions of nonlinear energy sink with a two degrees of freedom

system: Internal resonance,” Journal of Sound and Vibration, 2010, 329, pp. 1836–1852.

 J. J. Thomsen, Vibrations and Stability, 2nd edn, Springer, Berlin, 2003.

 A. A. Al-Qaisia and M. N. Hamdan, “Subharmonic resonance and transition to chaos of nonlinear oscillators with a combined softening and hardening nonlinearities,” Journal of Sound and Vibration, 2006, 305,

pp. 772–782.

 S. S. Rao, Engineering Optimization, John Wiley & Sons, New York, 1996, p.706.

 I. G. Currie, Fundamentals of Fluid Mechanics, McGraw-Hill, New York, 1993, p. 181.

 B. R. Munson, D. F. Young, and T. H. Okiishi, Fundamentals of Fluid Mechanics, 4th edn, John Wiley & Sons,

New York, 2002, p. 641.

 J. H. Duncan, Chapter 11, Fluid Mechanics, in E. B. Magrab, et al., An Engineer’s Guide to MATLAB, 3rd edn,

Prentice Hall, Upper Saddle River, New Jersey, 2011, p. 618.

 E. E. Lundquist and E. Z. Stowell, “Critical compressive stress for flat rectangular plates supported

along all edges and elastically restrained against rotation along the unloaded edges,” NACA Report 733,

1942.

Exercises

Section 5.2

5.1

Show numerically that

6

du

= cot −1 2

6 − u2

2

5.2

The total emissive power of a black body is determined from [5, p. 676]

Eb =

c1 d𝜆

) = 𝜎T 4

(

∫ 𝜆5 ec2 ∕(𝜆T) − 1

0

5.3

where c1 = 3.742 × 108 W μm4 ⋅m−2 , c2 = 1.4388 × 104 μm⋅K, and 𝜎 = 5.670 ×

10−8 W⋅m−2 ⋅K−4 . Show that for T = 500 K the difference between the exact solution

(right-hand side) and the approximate solution (numerical solution to the integral) is

0.006272%.

In determining the deflection of curved beams, the following relationship is obtained



𝛿(𝛽) = I1 (𝛽) + 1.3I2 (𝛽)

Numerical Evaluations of Equations

197

where 𝛿 is the nondimensional deflection, 𝛽 ≥ 0, and

1

I1 (𝛽) =

0

[

]2

−𝛽 2 𝜉 − (1 − 𝜉)

d𝜉

1 + y2

[ √

]2

𝛽 1 − 𝜉 2 + (1 − 𝜉)y

I2 (𝛽) =

d𝜉

1 + y2

1

0

−𝛽𝜉

y= √

1 − 𝜉2

5.4

Find the value of 𝛿(1.5).

Show numerically for z = 0.5 and y = 0.15 that

𝜋

(√

)

1

ey cos 𝜃 cos(z sin 𝜃)d𝜃 = J0

z2 − y2

𝜋∫

0

where J0 (x) is the Bessel function of the first kind of order zero.

Section 5.3

5.5

Determine the solution to the following system of nonlinear ordinary differential equations

dy1

= y2

dt

(

)

dy2

1

2 dL

=−

+ 𝛾L y2 − sin(y1 )

dt

L dt

L

over the range 0 ≤ t ≤ 30 where

L = 1 + 𝜀 sin7 (𝜔t + 9𝜋∕8)

dL

= 7𝜀𝜔 sin6 (𝜔t + 9𝜋∕8) cos(𝜔t + 9𝜋∕8)

dt

5.6

The initial conditions are y1 (0) = −1 and y2 (0) = 1 and the constants have the following

values: 𝜀 = 0.16, 𝛾 = 0.4, and 𝜔 = 0.97. Plot y1 (t) versus y2 (t) using ParametricPlot.

The nondimensional axial velocity Uz of blood in a large artery undergoing sinusoidal

oscillations can be can be determined from

𝜕Uz

= − sin 𝜏 + 𝛽

𝜕𝜏

(

1 𝜕

𝜂 𝜕𝜂

(

))

𝜕Uz

𝜂

𝜕𝜂

An Engineer’s Guide to Mathematica®

198

where 0 ≤ 𝜂 ≤ 1, 𝜏 is a nondimensional time, and 𝛽 is a constant. The initial condition

is

Uz (𝜂, 0) = 0

and the boundary conditions are

Uz (1, 𝜏) = 0

𝜕Uz |

|

=0

𝜕𝜂 ||𝜂=0

5.7

Solve this system and plot Uz as a function of 𝜂 and 𝜏, 0 ≤ 𝜏 ≤ 10, using Plot3D

when 𝛽 = 0.05. This equation has a discontinuity at 𝜂 = 0 so that the technique given

in Example 5.16 will have to be used.

The nondimensional equation for heat conduction in a slab is given by

𝜕𝜃 𝜕 2 𝜃

=

𝜕𝜏 𝜕𝜉 2

where 𝜃 = 𝜃(𝜉,𝜏) is proportional to the temperature in the slab. We are interested in the

region 0 ≤ 𝜏 ≤ 4.0 and 0 ≤ 𝜉 ≤ 1. The initial condition is 𝜃(𝜉,0) = 0 and the boundary

conditions are

𝜃(0, 𝜏) = 𝜏e−𝜏

𝜃(1, 𝜏) = 0

5.8

Solve this system and use Plot3D to display 𝜃.

The equilibrium equations in terms of nondimensional quantities that govern the large

deflections of a solid circular plate of constant thickness are given by [4, p. 402]

( )2

d2 u 1 du

1 − 𝜈 dw

dw d2 w

u

+

− 2 =−

2

𝜂 d𝜂 𝜂

2𝜂

d𝜂

d𝜂 d𝜂 2

d𝜂

[

( )2 ]

𝜂

u 1 dw

d2 w 1 dw w

dw du

+ qo

+

− 2 = ha

+𝜈 +

2

𝜂

d𝜂

d𝜂

d𝜂

𝜂

2

d𝜂

2

d𝜂

𝜂

If the plate is clamped along the outer boundary, the boundary conditions are

u(1) = 0,

w(1) = 0,

w′ (1) = 0

At the center of the plate, symmetry is used to require that

u(0.001) = 0,

w′ (0.001) = 0

Numerical Evaluations of Equations

199

where, to avoid the discontinuity at 𝜂 = 0, the center of the plate is approximated by a

hole of radius 𝜂 = 0.001.

The displacement of a solid circular plate using linear theory that is clamped at its

outer edge and subjected to a constant load is given by

w(𝜂) =

5.9

)

qo (

1 − 2𝜂 2 + 𝜂 4

64

Use these equations to plot the linear and nonlinear transverse displacements of the

plate when 𝜈 = 0.3, ha = 0.001, and qo = 10000.

The following three coupled nonlinear equations in terms of nondimensional quantities

are given 

d𝜃

= −v [𝜃 + (1 + 𝜀) ln v]

dt

du

= v−1

dt

[

]

dv

= −𝛾 2 u + (𝜃 + ln v)∕𝜉

dt

5.10

Obtain the solution to these equations when u(0) = v(0) = 1 and 𝜃(0) = 0 and for

𝜀 = 0.5, 𝛾 = 0.8, and 𝜉 = 0.5. Display the results two ways: as a plot of v(t) versus

t using Plot and as phase portrait of u(t) versus v(t) using ParametricPlot. In

both displays, let 0 ≤ t ≤ 1000.

Consider a curved cantilever beam of initial radius of curvature R, length L, Young’s

modulus E, and moment of inertia I. A load P is applied to the free end of the beam at

an angle 𝛼, where 𝛼 = 0 indicates a load that is parallel to the axis of the beam and an

angle 𝛼 = 𝜋/2 indicates a load perpendicular to axis of the beam. If s is the arc length

of the beam and 𝜑(s) is the slope of the centroidal axis of the beam, then the equation

from which the deflection of the beam can be determined is obtained from 

𝜃 ′′ (𝜂) + po 𝜃(𝜂) = 0

where 𝜂 = s/L, the prime denotes the derivative with respect to 𝜂, and

𝜑(𝜂) = 𝜃(𝜂) − 𝜃(L)

po =

PL2

EI

The boundary conditions are given by

𝜃(0) = 𝛼

and

𝜃 ′ (0) = −

L

R

An Engineer’s Guide to Mathematica®

200

The nondimensional Cartesian coordinates of a point 𝜂 on the beam are given by

1

x(𝜂) =

cos(𝜑(𝜌))d𝜌

𝜂

1

y(𝜂) =

sin(𝜑(𝜌))d𝜌

𝜂

which describe the deformed shape of the beam.

Determine the shape of the beam for the case of 𝛼 = 0 and po = {0.02, 3, 9,

12} and for the case of 𝛼 = 𝜋/2 and po = {0.02, 5, 15, 25, 35}. The results should

look like those shown in Figure 5.23. Assume that the initial shape of the beam

is a semicircle so that L/R = 𝜋. The sign of the y-coordinate has been changed to

obtain the curves shown in this figure. The topmost curve belongs to the largest value

of po .

0.6

0.4

0.5

0.2

–0.2

0.2

0.4

0.6

0.0

0.2

0.4

0.6

0.8

1.0

–0.2

–0.5

–0.4

–0.6

(a)

(b)

Figure 5.23 Solution to Exercise 5.10: (a) 𝛼 = 0 and po = {0.02, 3, 9, 12} (b) 𝛼 = 𝜋/2 and po = {0.02,

5, 15, 25, 35}

Xem Thêm
Tải bản đầy đủ (.pdf) (453 trang) ### Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×