Beruflich Dokumente
Kultur Dokumente
Fourier Series
On this page
w here a0 models a constant (intercept) term in the data and is associated w ith the i = 0 cosine term, w is the fundamental
frequency of the signal, n is the number of terms (harmonics) in the series, and 1 n 8.
For more information about the Fourier series, refer to Fourier Analysis and Filtering.
1/7
18/3/2014
Measure Period
Fit an Eight-Term Fourier Model
Measure Period
Examine Terms
Set Start Points
Find Fourier Fit Options
Fit a Tw o-Term Fourier Model
Load some data and fit an tw o-term Fourier model.
load enso;
f = fit(month,pressure,'fourier2')
plot(f,month,pressure)
f=
General model Fourier2:
f(x) = a0 + a1*cos(x*w) + b1*sin(x*w) +
a2*cos(2*x*w) + b2*sin(2*x*w)
Coefficients (with 95% confidence bounds):
a0 =
10.63 (10.23, 11.03)
a1 =
2.923 (2.27, 3.576)
b1 =
1.059 (0.01593, 2.101)
a2 =
-0.5052 (-1.086, 0.07532)
b2 =
0.2187 (-0.4202, 0.8576)
w=
0.5258 (0.5222, 0.5294)
The confidence bounds on a2and b2cross zero. For linear terms, you cannot be sure that these coefficients differ from
zero, so they are not helping w ith the fit. This means that this tw o term model is probably no better than a one term model.
Measure Period
The wterm is a measure of period. 2*pi/wconverts to the period in months, because the period of sin()and cos()is
2*pi.
http://www.mathworks.com/help/curvefit/fourier.html
2/7
18/3/2014
w = f.w
2*pi/w
w=
0.5258
ans =
11.9497
wis very close to 12 months, indicating a yearly period. Observe this looks correct on the plot, w ith peaks approximately 12
months apart.
Fit an Eight-Term Fourier Model
f2 = fit(month,pressure,'fourier8')
plot(f2,month,pressure)
f2 =
General model Fourier8:
f2(x) =
a0 + a1*cos(x*w) + b1*sin(x*w) +
a2*cos(2*x*w) + b2*sin(2*x*w) + a3*cos(3*x*w) + b3*sin(3*x*w) +
a4*cos(4*x*w) + b4*sin(4*x*w) + a5*cos(5*x*w) + b5*sin(5*x*w) +
a6*cos(6*x*w) + b6*sin(6*x*w) + a7*cos(7*x*w) + b7*sin(7*x*w) +
a8*cos(8*x*w) + b8*sin(8*x*w)
Coefficients (with 95% confidence bounds):
a0 =
10.63 (10.28, 10.97)
a1 =
0.5668 (0.07981, 1.054)
b1 =
0.1969 (-0.2929, 0.6867)
a2 =
-1.203 (-1.69, -0.7161)
b2 =
-0.8087 (-1.311, -0.3065)
a3 =
0.9321 (0.4277, 1.436)
b3 =
0.7602 (0.2587, 1.262)
a4 =
-0.6653 (-1.152, -0.1788)
b4 =
-0.2038 (-0.703, 0.2954)
a5 =
-0.02919 (-0.5158, 0.4575)
b5 =
-0.3701 (-0.8594, 0.1192)
a6 =
-0.04856 (-0.5482, 0.4511)
b6 =
-0.1368 (-0.6317, 0.3581)
a7 =
2.811 (2.174, 3.449)
b7 =
1.334 (0.3686, 2.3)
a8 =
0.07979 (-0.4329, 0.5925)
b8 =
-0.1076 (-0.6037, 0.3885)
w=
0.07527 (0.07476, 0.07578)
http://www.mathworks.com/help/curvefit/fourier.html
3/7
18/3/2014
Measure Period
w = f2.w
(2*pi)/w
w=
0.0753
ans =
83.4736
4/7
18/3/2014
equations. You can override the start points and specify your ow n values.
After examining the terms and plots, it looks like a 4 year cycle might be present. Try to confirm this by setting w. Get a value
for w, w here 8 years = 96 months.
w = (2*pi)/96
w=
0.0654
Find the order of the entries for coefficients in the model ('f2') by using the coeffnamesfunction.
coeffnames(f2)
ans =
'a0'
'a1'
'b1'
'a2'
'b2'
'a3'
'b3'
'a4'
'b4'
'a5'
'b5'
'a6'
'b6'
'a7'
'b7'
'a8'
'b8'
'w'
0.5668
0.1969
-1.2031
-0.8087
0.9321
0.7602
-0.0292
-0.3701
-0.0486
-0.1368
2.8112
Columns 8 through 14
-0.6653
-0.2038
Columns 15 through 18
1.3344
0.0798
-0.1076
0.0753
http://www.mathworks.com/help/curvefit/fourier.html
5/7
18/3/2014
Columns 1 through 7
10.6261
0.5668
0.1969
-1.2031
-0.8087
0.9321
0.7602
-0.0292
-0.3701
-0.0486
-0.1368
2.8112
Columns 8 through 14
-0.6653
-0.2038
Columns 15 through 18
1.3344
0.0798
-0.1076
0.0654
Set the start points for coefficients using the new value for w.
f3 = fit(month,pressure,'fourier8', 'StartPoint', coeffs);
Plot both fits to see that the new value for win f3does not produce a better fit than f2.
plot(f3,month,pressure)
hold on
plot(f2, 'b')
hold off
legend( 'Data', 'f3', 'f2')
ans =
http://www.mathworks.com/help/curvefit/fourier.html
6/7
18/3/2014
Normalize: 'off'
Exclude: []
Weights: []
Method: 'NonlinearLeastSquares'
Robust: 'Off'
StartPoint: [1x0 double]
Lower: [1x0 double]
Upper: [1x0 double]
Algorithm: 'Trust-Region'
DiffMinChange: 1.0000e-08
DiffMaxChange: 0.1000
Display: 'Notify'
MaxFunEvals: 600
MaxIter: 400
TolFun: 1.0000e-06
TolX: 1.0000e-06
If you w ant to modify fit options such as coefficient starting values and constraint bounds appropriate for your data, or change
algorithm settings, see the options for NonlinearLeastSquares on the fitoptionsreference page.
See Also
fit| fitoptions| fittype
Related Examples
Custom Nonlinear ENSO Data Analysis
Specifying Fit Options and Optimized Starting Points
http://www.mathworks.com/help/curvefit/fourier.html
7/7