Does anyone know how to generate a square wave as a sum of sine waves using matlab code? I know how to generate a square wave using the 'square' command but I have NO IDEA how to do it using fourier series. Won't someone PLEEEAAASE help me out? I'm really desperate here.:(Sara Lauren.
- chjmartin2
- Newbie
- Posts: 16
- Joined: Jun 24, 2011
- Logged
Is the Fourier Transform or Series of a Square Wave more Accurate?
What is a more accurate representation of the frequency component of a square wave? The Fourier Transform or a very large expanded Fourier Series.
If you look at the above image, it shows you the relatively trivial Fourier Series expansion of a square wave. It is the Frequency then a third of the 3rd harmonic, 5th of the fifth harmonic and so forth on to forever....
BUT....
If we do the Fourier TRANSFORM of the square wave we can use the picture below to visualize it:
So which one is correct? Is a square wave made up of the summation of discontinuous frequencies at the base plus every other odd harmonic up to infinity OR does it have a continuous frequency spectrum with SOME frequency content between the harmonics? Here is one more, but it is a Youtube video:
Square Wave Harmonics
So... in his video he shows how the harmonics should show up, demonstrates it on his scope using the generator, but then doesn't say anything about the apparent lower level harmonics at the even multiples?!?
Lastly, if I go ahead and use Cool Edit (yes, it will always be Cool Edit for me) to generate a square wave and do the FFT on it using multiple windows I still see frequency content at the other harmonics.
The reason I ask is this. If I were to play two perfect square waves of two different frequencies. Is the frequency content really only the odd harmonics of both signals, or would it be the addition of the two Sinc functions?
(This is not homework by the way...)