0

I have the following discrete data (6001 data points) stored in the external file called analysis: the format of data set as:

-0.32026    -0.00185
-0.32016    0.00488
-0.32005    0.01161
-0.31994    0.01834
-0.31983    0.02507
-0.31973    0.0318
-0.31962    0.03853
-0.31951    0.04526
-0.31941    0.05199

what I want is to fit the data by Fourier series, and get fitting parameters $C_n$ (n>20)

$\qquad y=\sum_n c_n \cos(nk)$,

code likes the following:

list = Import["C:\Users\mxguan\Desktop\analysis.txt", "Table"]

bothfit = Fit[list, Flatten[Table[{Cos[n*x], Sin[n*x]}, {n, 0, end}]], x];

Grid[
Table[
bothfit = 
Fit[list, Flatten[Table[{Cos[n*x], Sin[n*x]}, {n, 0, end}]], x];

{
Show[{
ListPlot[list, PlotRange -> All, Joined -> True, 
PlotStyle -> Directive[Red, Thickness[0.015]]],

Plot[bothfit, {x, list[[1, 1]], list[[-1, 1]]}, 
PlotRange -> All,PlotStyle -> Black]}, PlotRange -> {-10, 10}, 
ImageSize -> 350, PlotLabel -> 
"Both Fit: n = " <> "0.." <> ToString[end]]
}
, {end, {70}}]
]

however,during the calculation,there are some error raiesd:

Table::iterb: Iterator {n,0,end} does not have appropriate bounds.

General::stop: Further output of Table::iterb will be suppressed during this calculation.

Fit::fitm: Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted.

The result is that only fitting curve are plot, but I can not find the fitting parameter,is there any fault in a input?

enter image description here

mxguan
  • 1
  • 1

0 Answers0