I have two arrays contain $y$ and $k$,respectively. However, the exact function relationship is not clear. What I what to do is to fit $y(k)$ by Fourier series

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

up to $n>20$ terms and obtain their coefficients $c_n$. Can anyone help me? I would be very grateful for your kindness.

  • 1
    $\begingroup$ Duplicate of this, I believe. $\endgroup$ Oct 23, 2017 at 12:47
  • $\begingroup$ Thanks,but when I try to fit my data, there is fitted curves but no fitting parameters. Meanwhile, an error raised. ' Fit::fitm: Unable to solve for the fit parameters; the design matrix is nonrectangular, non-numerical, or could not be inverted.' why is that? $\endgroup$
    – mxguan
    Oct 25, 2017 at 3:40
  • $\begingroup$ It is not possible to answer your questions without more information about the data and the code used to fit the data. My first guess is that you are not using the NonlinearModelFit function correctly, and need to look at the documentation and the referenced Stack Exchange questions for examples. $\endgroup$ Oct 25, 2017 at 12:54


Browse other questions tagged or ask your own question.