# Plotting fourier series approximation of F(t)

• Oct 30th 2008, 04:26 AM
mslodyczka
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
• Oct 30th 2008, 08:39 AM
ThePerfectHacker
Quote:

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 $\displaystyle f(t) = f(t+2)$ you make a periodic function.

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

If $\displaystyle N$ is a large number then $\displaystyle \sum_{n=0}^N a_n \cos \frac{\pi n t}{2}$ will approximate $\displaystyle f(t)$.
Take something like $\displaystyle N=50,100,200$ and see how the curves approximate the function.
• Oct 30th 2008, 02:56 PM
mslodyczka
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.