# The Fourier Series Of This Triangle Wave

I am using matlab to study digital signalling and have come across a problem which i was wondering if anyone with more experience could help me with.

I need to work derive the Fourier series of a triangle wave that i have generated, I just do not know how to actually go about this problem in Matlab.

I am generating a 100hz Triangle signal using the following code:

t = 0:1/10000:1;
f=100;
x1 = sawtooth(2*pi*f*t, 0.5);
plot(t,x1);
axis([0 0.10 -1 1]);


Now how should i go about deriving the Fourier series of this signal, i am completely lost.

Any help would be appreciated.

• Triangle and sawtooth are not the same waveform. Which is the one you want to analyze? – Phonon Mar 16 '12 at 18:09

Check out Wikipedia's Fourier Series page. Their "Example 1" shows how to derive the Fourier series of a sawtooth wave. All you have to do is normalize the results for your particular time and amplitude values.

If the modulus of the slope of your sawtooth voltage is A, then your Fourier Co-efficient, if you are talking about a continuous time fourier series, is

Cn=-(ATo/((npi)^2))((Sin((npi)/2))^2)

Hint: double differentiate your signal till you end up with dirac delta functions, they are easy to modify.

I assume you want to calculate the FFT of this signal in MATLAB? This would be like this:

N_fft = 2^15; %Just an FFT size
x1_fft = fft(x1, N_fft); %Take the FFT.
plot(abs(x1_fft));

• This is not the same as computing Fourier Series. The difference is that Fourier Series comes from continuous Fourier Transform, while FFT comes from discrete Fourier Transform. – Phonon Mar 16 '12 at 18:23
• @Phonon: Aren't they identical except for the Fourier Series having an infinite number of harmonics? – endolith Mar 16 '12 at 18:34
• @Phonon This is why I asked him if what he really wants is to compute the FFT of the signal, and not really 'deriving the fourier series'. – Spacey Mar 16 '12 at 19:01
• @Mohammad If you zoom in on one of the peaks in your plot, it's not really a peak. It's a lobe. That's why I would be more careful. You're essentially windowing your signal with a rectangle and getting characteristic of a sinc in your frequency plot. – Phonon Mar 16 '12 at 19:25
• @Phonon Sorry Im not following you... the OP sounds like he just wants to FFT his signal in MATLAB, and being new to the field might be (understandably) getting exact fourier lingo mixed up, what with distinctions between fourier co-efficients VS an FFT, VS a CFT, etc etc. We need more feedback from him. – Spacey Mar 16 '12 at 19:38