I have examples of Fourier series and I would using the Matlab I know how calculate the coefficients of Fourier series in Matlab
but how calculate the summation ? do I use “For loop “ or what in Matlab
I have examples of Fourier series and I would using the Matlab I know how calculate the coefficients of Fourier series in Matlab
but how calculate the summation ? do I use “For loop “ or what in Matlab
Copyright © 2021 JogjaFile Inc.
let $P$ be the period of your original function $F(x)$. Let $F_N(x)$ be the function that is made from the first $N$ coefficients of the Fourier series. Then:
$$F_N(x) = a_0 + \sum_{n=1}^N\bigg[a_n\cos\bigg(\frac{2\pi n x}{P}\bigg)+b_n\sin\bigg(\frac{2\pi nx}{P}\bigg)\bigg]$$
Where $a_i$ and $b_i$ are your coefficients.
Let's say that you have two vectors in MATLAB named
anandbn, and the period of the original function is stored in a variableP, and the point $x$ is stored in a variablex. Then this should work:If you are using a different definition of $F_N(x)$ then the above code can be modified accordingly. This should get you started.