![Page 1: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/1.jpg)
Environmental Data Analysis with MatLab
Lecture 10:
Complex Fourier Series
![Page 2: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/2.jpg)
Lecture 01 Using MatLabLecture 02 Looking At DataLecture 03 Probability and Measurement Error Lecture 04 Multivariate DistributionsLecture 05 Linear ModelsLecture 06 The Principle of Least SquaresLecture 07 Prior InformationLecture 08 Solving Generalized Least Squares ProblemsLecture 09 Fourier SeriesLecture 10 Complex Fourier SeriesLecture 11 Lessons Learned from the Fourier TransformLecture 12 Power SpectraLecture 13 Filter Theory Lecture 14 Applications of Filters Lecture 15 Factor Analysis Lecture 16 Orthogonal functions Lecture 17 Covariance and AutocorrelationLecture 18 Cross-correlationLecture 19 Smoothing, Correlation and SpectraLecture 20 Coherence; Tapering and Spectral Analysis Lecture 21 InterpolationLecture 22 Hypothesis testing Lecture 23 Hypothesis Testing continued; F-TestsLecture 24 Confidence Limits of Spectra, Bootstraps
SYLLABUS
![Page 3: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/3.jpg)
purpose of the lecture
switch from Fourier Series containing
sines and cosines
to Fourier Series containing
complex exponentials
![Page 4: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/4.jpg)
purpose of the lecture
switch from Fourier Series containing
sin(ωt) and cos(ωt)
to
Fourier series containing
exp(-iωt) and exp(+iωt)
![Page 5: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/5.jpg)
review of complex numbers
![Page 6: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/6.jpg)
imaginary unit
i
such thati2 = -1
![Page 7: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/7.jpg)
complex number
a = ar + i aireal part
imaginary part
![Page 8: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/8.jpg)
adding complex numbers
a = ar + i ai b = br + i bic = a+b = (ar + i ai )+ (br + i bi ) = (ar + br )+ i(ai +bi ) cr ci … just add real and imaginary parts, separately
![Page 9: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/9.jpg)
subtracting complex numbers
a = ar + i ai b = br + i bic = a-b = (ar + i ai )-(br + i bi ) =
(ar - br )+ i(ai - bi ) cr ci … just subtract real and imaginary parts, separately
![Page 10: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/10.jpg)
multiplying complex numbersa = ar + i ai b = br + i bic = ab = (ar + i ai )(br + i bi ) == ar br + i ar bi + i ai br + i2 ai bi = (ar br - ai bi )+ i(ar bi + ai br ) cr ci … like multiplying polynomials
![Page 11: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/11.jpg)
complex conjugate, a*a = ar + i ai a* = ar - i ai
![Page 12: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/12.jpg)
absolute value, |a ||a | = [ ar2 + ai2 ]½
note |a |2 = a* a
![Page 13: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/13.jpg)
Euler’s Formula
exp(iz) = cos(z) + i sin(z)
… where does that come from ???
![Page 14: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/14.jpg)
start from the Taylor series expansions
exp(x) = 1 + x + x2/2 + x3/6 + x4/24 + …cos(x) = 1 + 0 - x2/2 + 0 + x4/24 + …
sin(x) = 0 + x + 0 - x3/6 +0 + …
![Page 15: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/15.jpg)
exp(x)substitute in x=izexp(x) = 1 + x + x2/2 + x3/6 + x4/24 + …exp(iz) = 1 + iz - z2/2 - iz3/6 + z4/24 + …
![Page 16: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/16.jpg)
cos(x)substitute in x=zcos(x) = 1 + 0 - x2/2 + 0 + x4/24 + … cos(z) = 1 + 0 - z2/2 + 0 + z4/24 + …
![Page 17: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/17.jpg)
sin(x)substitute in x=z and multiply by i sin(x) = 0 + x + 0 - x3/6 +0 + … i sin(z) = 0 + iz + 0 - iz3/6 +0 + …
![Page 18: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/18.jpg)
add cos(z) and i sin(z)cos(z) = 1 + 0 - z2/2 + 0 + z4/24 + …+i sin(z) = 0 + iz + 0 - iz3/6 +0 + …=cos(z) + i sin(z) = 1 + iz - z2/2 - iz3/6 + z4/24 + … compare with results for exp(iz)exp(iz) = 1 + iz - z2/2 - iz3/6 + z4/24 + … they’re equal!
![Page 19: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/19.jpg)
note that since
exp(iz) = cos(z) + i sin(z)then |exp(iz) |= cos2(z) + sin2 (z) = 1
![Page 20: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/20.jpg)
any complex number can be written
z = r exp(iθ) where r = |z | and θ=tan-1(zi/zr)
![Page 21: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/21.jpg)
MatLabhandles complex numbers completely transparently
a = 2 + 3*i;b = 4 + 6*i;c = a+b;
works just fine
![Page 22: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/22.jpg)
Warning!accidentally resetting i to something
other than i is so easy i=100;
(and then you get nonsense)
so execute aclear i;
at the top of your script if you plan to use i
![Page 23: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/23.jpg)
or use the alternate notation
a = complex(2,3);b = complex(4,6);
c = a+b;
which is safer
![Page 24: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/24.jpg)
end of review
![Page 25: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/25.jpg)
Euler’s Formulascomplex exponentials can be written as sines and cosines
![Page 26: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/26.jpg)
or reverse themsine and cosines can be written as complex exponentials
![Page 27: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/27.jpg)
so a Fourier Seriesalternatively can be written
as a sum of sines and cosinesor a sum of complex exponentials
![Page 28: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/28.jpg)
paired terms
sines and cosines of the same frequency, ω, are paired
andpositive and negative complex exponentials of the frequencies, ω,
are paired
… so as to be able to represent a time-shifted sinusoid
![Page 29: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/29.jpg)
A and B and C- and C+must be related
![Page 30: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/30.jpg)
A B =0impliesC I- = -CI+
=0impliesCR + = CR-
![Page 31: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/31.jpg)
summary
Cr is an even function of frequency
Ci is an odd function of frequency
coefficients at corresponding positive and negatives are complex conjugates
C(-ω) = C*(ω)
![Page 32: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/32.jpg)
ωCrCi
illustration of symmetry of
![Page 33: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/33.jpg)
old-style Fourier Series
non-negative frequencies only
from0 to ωny
![Page 34: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/34.jpg)
new-style Fourier Seriesor “Inverse Discrete Fourier Transform”
non-negativefrequencies
negativefrequencies
added for compatibility with MatLab
![Page 35: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/35.jpg)
why the weird ordering of frequencies?
ωn = ( 0, Δω, 2Δω, …, N½ Δω, -( N½ -1) Δω, …, -2 Δω, -Δω )
same asωn = ( 0, Δω, 2Δω, …, N½ Δω, ( N½ +1) Δω, …, (N-1)Δω, NΔω )
non-negativefrequencies
negativefrequencies
non-negative frequencies up to
Nyquist
non-negativefrequencies above the Nyquist
![Page 36: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/36.jpg)
least-squares solution for the Fourier coefficients, Cn or “Discrete Fourier Transform”
… derivation requires complex version of least-
squares. See text of details …
![Page 37: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/37.jpg)
MatLab
Fourier Coefficients Cj from time series dn
c = fft(d);
vector of N datavector of N complex Fourier
coefficients
![Page 38: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/38.jpg)
MatLab
time series dn from Fourier Coefficients Cj d = ifft(c);
vector of N data
vector of N complex Fourier
coefficients
![Page 39: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/39.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
![Page 40: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/40.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
same number M of Fourier Coefficients as number N of data
![Page 41: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/41.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
maximum time, for N data sampled at Dt
![Page 42: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/42.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
time column-vector
![Page 43: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/43.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
Nyquist frequency, fny
![Page 44: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/44.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
frequency sampling, Δf
![Page 45: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/45.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
frequency column- vector
![Page 46: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/46.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
number of frequencies between 0 and Nyquist
![Page 47: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/47.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
angular frequency sampling, Δω
![Page 48: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/48.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf;
angular frequency
column- vector
![Page 49: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/49.jpg)
standard setupM=N; tmax=Dt*(N-1); t=Dt*[0:N-1]'; fmax=1/(2.0*Dt); df=fmax/(N/2); f=df*[0:N/2,-N/2+1:-1]'; Nf=N/2+1; dw=2*pi*df; w=dw*[0:N/2,-N/2+1:-1]'; Nw=Nf; number of angular frequencies between 0 and Nyquist
![Page 50: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/50.jpg)
Computing Power Spectral Density
% compute Fourier coefficients mest = fft(d);
% compute amplitude spectral density s=abs(mest(1:Nw));
% compute power spectral density s2=s^2;
![Page 51: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/51.jpg)
Spectral Density
% compute Fourier coefficients mest = fft(d);
% compute amplitude spectral density s=abs(mest(1:Nw));
% compute power spectral density s2=s^2;
note that negative frequencies are discardedsince they are redundant
![Page 52: Environmental Data Analysis with MatLab Lecture 10: Complex Fourier Series](https://reader038.vdocument.in/reader038/viewer/2022102616/5519d07e550346047c8b4bd2/html5/thumbnails/52.jpg)
Why The Switch to Complex?
One function, exp(), is better than two, cos() & sin()exp() is algebraically simpler than cos() & sin(),
e.g.
exp(a) / exp(b) = exp( a – b)which substantially simplifies formulasTradition – that’s the way everyone does it! Or more
importantly, that’s the way MatLab does it.