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;
x1 = sawtooth(2*pi*f*t, 0.5);
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.

  • 2
    $\begingroup$ Triangle and sawtooth are not the same waveform. Which is the one you want to analyze? $\endgroup$
    – Phonon
    Commented Mar 16, 2012 at 18:09

3 Answers 3


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


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.
  • 2
    $\begingroup$ 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. $\endgroup$
    – Phonon
    Commented Mar 16, 2012 at 18:23
  • 1
    $\begingroup$ @Phonon: Aren't they identical except for the Fourier Series having an infinite number of harmonics? $\endgroup$
    – endolith
    Commented Mar 16, 2012 at 18:34
  • $\begingroup$ @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'. $\endgroup$
    – Spacey
    Commented Mar 16, 2012 at 19:01
  • $\begingroup$ @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. $\endgroup$
    – Phonon
    Commented Mar 16, 2012 at 19:25
  • $\begingroup$ @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. $\endgroup$
    – Spacey
    Commented Mar 16, 2012 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.