Complex Fourier Series using Matlab

Click For Summary
SUMMARY

The discussion centers on synthesizing a complex Fourier series using Matlab for a specific periodic function defined over the intervals -1 to 1. The coefficients are given by Cn = 2/πn, with Co being 0. The user initially struggled to recreate the time domain signal due to incorrect period settings in Matlab, specifically using t=linspace(0,2π) instead of the correct domain from -π to +π. After correcting this mistake and understanding the need for multiple terms in the series, the user successfully generated the desired waveform.

PREREQUISITES
  • Understanding of complex Fourier series and their coefficients
  • Familiarity with Matlab programming and syntax
  • Knowledge of periodic functions and their properties
  • Basic grasp of trigonometric identities and transformations
NEXT STEPS
  • Learn how to implement Fourier series in Matlab using the 'fft' function
  • Study the Gibbs phenomenon and its implications on waveform reconstruction
  • Explore the effects of varying the number of terms in Fourier series on signal approximation
  • Investigate the use of linspace and its parameters for defining time domains in Matlab
USEFUL FOR

Matlab users, signal processing engineers, and students studying Fourier analysis who seek to understand the synthesis of complex Fourier series and their practical implementation in software.

Jag1972
Messages
40
Reaction score
0
Hello,
I have a problem synthesising the complex Fourier series using Matlab. The time domain periodic function is:

-1, -1.0 ≤ t < -0.5
1 , -0.5≤ t <0.5
-1, 0.5 ≤ t < 1

The single non zero coefficient is: Cn = \frac{2}{\pi n}, Co is 0 (average is 0).

f(t)= \sum Cn e^{jnwt} (limits are -∞ to ∞, could not find the latex symbol)

This makes:

f(t) = (\frac{2}{\pi} e^{jwt} - \frac{2}{\pi*3} e^{j3wt} + \frac{2}{\pi*5} e^{j5wt} -... \frac{2}{\pi*∞} e^{j∞wt}) + (\frac{2}{\pi} e^{-jwt} - \frac{2}{\pi*3} e^{-j3wt} + \frac{2}{\pi*5} e^{-j5wt} -... \frac{2}{\pi*∞} e^{j-∞wt})

In order to enter this in Matlab I have combined the exponential terms to obtain cosine waves.
For example when n=1 and n=-1.

\frac{2}{\pi} e^{jwt} + \frac{2}{\pi} e^{-jwt}

\frac{2}{\pi}( e^{jwt} + e^{-jwt})

\frac{4}{\pi}( \frac{e^{jwt}+e^{-jwt}}{2})

\frac{4}{\pi}( cos wt)

when n=2 and n=-2.

\frac{-4}{\pi*3}( cos 3wt)

So I end up with cosine terms which only exist for odd multiples of 'n' and the '+' and '-' sign alternates.
When I enter this in Matlab I can not recreate my time domain signal. Could someone please offer me some advice on where I have gone wrong.

Jag.
 
Physics news on Phys.org
You are doing the right things, but the details went wrong somewhere. Your input square wave has a period of 2 seconds, but a term like ##\cos \omega t## in your Fourier series has a period of ##2\pi## seconds.

It looks like this was wrong from the start, when you said ##f(t) = \sum C_n e^{jn\omega t}##.

Note you will need several terms (say 10) before you get something that looks close to a square wave, and see http://en.wikipedia.org/wiki/Gibbs_phenomenon for why a finite number of terms in the series will never look "exactly" like a square wave.
 
Alphazero: Thank you very much for your reply. Although I did not show itin my post I did actually enter ω = π into matlab.
However I did make a big mistake which was I entered t=linspace(0,2π), without realising that my domain is from -π to +π, doh!.
I have now got the right shape, thanks ever so much as I was doubting my working out.

Jag.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K