# Thread: Plotting fourier series approximation of F(t)

1. ## Plotting fourier series approximation of F(t)

Hi all,

I'm new to matlab and have a question for a class i'm taking. I've worked out everything except for the last part - which i'm absolutely stuck on...

F(t) is the function;

f(t) = t-1 for 1<t<2
= t for 0 <t<1

I had to determine a fourier representation of this analytically which is all done, but now I have absolutely no idea how to do a fourier series approximation in Matlab. I've checked countless sites and books but they typcailly go into heaps of detail and I get lost after a few lines of code...

Any help would be appreciated.

Cheers,
Mike

2. Originally Posted by mslodyczka
Hi all,

I'm new to matlab and have a question for a class i'm taking. I've worked out everything except for the last part - which i'm absolutely stuck on...

F(t) is the function;

f(t) = t-1 for 1<t<2
= t for 0 <t<1
If you define $f(t) = f(t+2)$ you make a periodic function.

The Fourier series shall be only of cosines since $f$ is even.
Thus, it would look like, $f(t) = \sum_{n=0}^{\infty}a_n \cos \frac{\pi n t}{2}$ where the coefficients $a_n$ are determined by formula.

If $N$ is a large number then $\sum_{n=0}^N a_n \cos \frac{\pi n t}{2}$ will approximate $f(t)$.
Take something like $N=50,100,200$ and see how the curves approximate the function.

3. Hi,
Thanks. I get that part, what i'm stuck with is actually coming up with the Matlab code to get the coefficients and then plotting the approximation.