Writing function for n-term Fourier series?

Using the fit function, the maximum number of terms that can be made using a Fourier fit in MATLAB is 8:
f = fit(xs,ys,'fourier8')
Unfortunately, an 8-term series isn't going to cut it for my purposes. The goal is to fit a data set with a Fourier model and extract the coefficients, and the coefficients need to be as precise as possible for later analysis. I was wondering if anyone had an idea of how to modify the pre-existing fit function using:
fitoptions('fourier8')
that would create a n-numbered term Fourier series, where n is customizeable (yet finite). If this is unfeasible, how one would go about writing a program that creates an n-term Fourier series with extractable coefficients using the general formula in the image attached (fouriersum.jpg) where the upper bound isn't actually infinity as we are looking to go to a finite n-number.
Thanks in advance!

Answers (0)

This question is closed.

Products

Release

R2014a

Asked:

on 7 Jun 2018

Closed:

on 18 Jun 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!