A game with Fourier coefficients/transform

In summary: Aliasing" in the frequency spectrum of the output signal. The original carrier wave will be aliased into many different frequencies, depending on the relative frequencies of the two input signals.For example, if you sampled a RF signal at 100 kHz and then amplitude modulated that same signal with a 10 kHz signal, you would get a spectrum that looks like this:You would see a lot of aliasing in the frequencies between 10 kHz and 100 kHz, as well as in the 100 kHz frequency itself.
  • #1
Bassalisk
947
2
So I am playing this game.


Guess the signal from its amplitude spectrum(FFT). Signal is periodic. I am currently playing with square wave and what are its characteristics. I am using MATLAB function square to do this.

I set the sampling to 500 Hz.

So above 250 Hz I get aliasing.


So far I got this:

When I use frequencies that are well below 250Hz, 150Hz for example, I get a clear delta in amplitude spectrum at 150 Hz.

http://pokit.org/get/c9a4f5cd7e2b0fc3d461c113f8c2e833.jpg


Another example is for 100 Hz

http://pokit.org/get/821f8411db350e1ac31c2ec168251b68.jpg

I concluded that at even Frequencies I get a delta in 0.(even frequencies like 100 120 Hz etc). Why is that?


And for frequencies between like 100Hz 150Hz I get all these little harmonics, like so:

http://pokit.org/get/e3ca4d9d81017657a4965ce5db9577d1.jpg

Can anybody explain this to me? Why do I get these small harmonics? This is closely related to the sampling which is at 500 Hz, and most weird case of all:

At 240 Hz:

http://pokit.org/get/a49e3210ca2067d5b7a20ce61038d659.jpg

I am completely baffled with these small harmonics!

Can any signal wizard, relate these small harmonics with sampling rate?

Thanks
 
Last edited by a moderator:
Engineering news on Phys.org
  • #2
You explained it all yourself.

So above 250 Hz I get aliasing.

Find out what is the frequency spectrum of a square wave, and what aliasing does, and everything will be explained.

If you want to try to understand it just by drawing pictures, try setting the sampling frequency higher, e.g. about 20 times the signal frequency, and DON'T make the two frequences simple ratios of each other. Try something like 2000 Hz and 103 Hz.
 
  • #3
AlephZero said:
You explained it all yourself.



Find out what is the frequency spectrum of a square wave, and what aliasing does, and everything will be explained.

If you want to try to understand it just by drawing pictures, try setting the sampling frequency higher, e.g. about 20 times the signal frequency, and DON'T make the two frequences simple ratios of each other. Try something like 2000 Hz and 103 Hz.

Yes, when I don't make the simple ratios, I get all these small harmonics. And when the ratio is "nice" I get fewer harmonics.

Can you give me a clue why is this so?
 
  • #4
What you are seeing are not referred to as "harmonics" (which are multiples of a fundamental frequency). They are referred to as alias components.
There are fewer visible components when there is a simple ratio between sampled and sampling frequencies because many of them occur at the same frequency. When the frequencies have a more complicated relationship, all these artefacts occur at different frequencies so each one is visible in its own right.
If you do this in real time, you can see the products moving about, combining and splitting as you change the frequency of the sampled signal.
 
  • #5
AlephZero said:
If you want to try to understand it just by drawing pictures, try setting the sampling frequency higher, e.g. about 20 times the signal frequency, and DON'T make the two frequences simple ratios of each other. Try something like 2000 Hz and 103 Hz.

Bassalisk said:
Yes, when I don't make the simple ratios, I get all these small harmonics.

Did you try the numbers I suggested? If you did, you should be able to see the "genuine" harmonics of the square wave (at 1, 3, 5, 7 ... times the fundamental frequency, with amplitudes 1, 1/3, 1/5, 1/7, ...) and also see how the harmonics that don't fit on the plot are "reflected off the ends of the plot", which is called aliasing.

The pictures you already posted are probably misleading you, because the two different things are too mixed up together and sometimes several different "peaks" are plotted on top of each other, so you can't easily make sense of the plot.
 
  • #6
AlephZero said:
Did you try the numbers I suggested? If you did, you should be able to see the "genuine" harmonics of the square wave (at 1, 3, 5, 7 ... times the fundamental frequency, with amplitudes 1, 1/3, 1/5, 1/7, ...) and also see how the harmonics that don't fit on the plot are "reflected off the ends of the plot", which is called aliasing.

The pictures you already posted are probably misleading you, because the two different things are too mixed up together and sometimes several different "peaks" are plotted on top of each other, so you can't easily make sense of the plot.

Yes I did. I am trying to interpret the graphs. I noticed some things about aliasing. Just I need to understand, somehow WHY do these small harmonics occur like they do.

Sophie said its because aliasing, just need to understand how is that happening, why all those small components.
 
  • #7
Try calling them spectral components. Not all spectral components are harmonics!.

When you sample a signal you are effectively Modulating the sampling signal with the signal that is being sampled.

If you Amplitude Modulate an RF sinewave (a 'carrier wave') with another sinewave (a much lower frequency signal, often referred to as the baseband signal), the resulting spectrum will be a peak at the carrier frequency with two sidebands, spaced above and below carrier frequency and separated from the carrier by the modulating sinewave frequency. Ordinary AM signals have identical (mirror image) upper and lower sidebands with the same spectrum as the baseband signal.

Sampling can be looked upon as modulating, not an RF sinewave but a high frequency string of pulses or even squarewaves with the baseband signal. The string of pulses will consist of a 'comb' of harmonics (using the term in the correct context here) and when you modulate it, each of the harmonics will have sidebands. The baseband information is duplicated as sidebands on each of the harmonics.

If you reduce the sampling frequency to the point where the spacing between its harmonics is smaller than the maximum frequency of the baseband signal then the structures will start to overlap and sometimes the lines will coincide (so some will seem to have disappeared). When you want to reconstruct the original signal from the samples, the components are all mixed up. The term 'foldback' is sometimes used because the high baseband frequencies can turn up as low frequency 'aliases'. That's why they say (Nyquist) that you must always sample at at least twice the highest frequency contained in the baseband signal if you want to avoid the possibility of aliasing.

If you are starting with a baseband signal that is a square wave, it will have a complex spectrum with many harmonics which will extend way up to the sampling frequency. If you sample it without some pre-filtering (Nyquist filtering) then you will get aliasing. Start with a sinewave at baseband and then a low-pass filtered squarewave. This should then start to make sense.

Sometimes - or even always - it is better to invest in some basic theory before launching into simulations. Maths has no 'common sense' and only does exactly what you have told it to do! Numerical analysis can be even worse.
 
  • #8
Bassalisk said:
Just I need to understand, somehow WHY do these small harmonics occur like they do.

The don't "occur". They aren't real. They are just an artefact of the way you are processing the data. If you want to use FFTs to do anything serious, you filter them out of the data before you do the FFT.

Make a table of sin(0.1t) for t = 0, 1, 2, 3, ...
Repeat, for sin(-0.1 t)
Repeat, for sin(6.38318 t) (6.38318 = 2 pi + 0.1)
Repeat, for sin(6.18318 t)

That's all there is to it. If all you have is the sampled data, you can't tell the difference between sine waves at 0.1 Hz and 6.38318 Hz (or 2 k pi + 0.1 Hz for any integer value of k). The FFT algorithm can't tell the difference either.
 
  • #9
sophiecentaur said:
Try calling them spectral components. Not all spectral components are harmonics!.

When you sample a signal you are effectively Modulating the sampling signal with the signal that is being sampled.

If you Amplitude Modulate an RF sinewave (a 'carrier wave') with another sinewave (a much lower frequency signal, often referred to as the baseband signal), the resulting spectrum will be a peak at the carrier frequency with two sidebands, spaced above and below carrier frequency and separated from the carrier by the modulating sinewave frequency. Ordinary AM signals have identical (mirror image) upper and lower sidebands with the same spectrum as the baseband signal.

Sampling can be looked upon as modulating, not an RF sinewave but a high frequency string of pulses or even squarewaves with the baseband signal. The string of pulses will consist of a 'comb' of harmonics (using the term in the correct context here) and when you modulate it, each of the harmonics will have sidebands. The baseband information is duplicated as sidebands on each of the harmonics.

If you reduce the sampling frequency to the point where the spacing between its harmonics is smaller than the maximum frequency of the baseband signal then the structures will start to overlap and sometimes the lines will coincide (so some will seem to have disappeared). When you want to reconstruct the original signal from the samples, the components are all mixed up. The term 'foldback' is sometimes used because the high baseband frequencies can turn up as low frequency 'aliases'. That's why they say (Nyquist) that you must always sample at at least twice the highest frequency contained in the baseband signal if you want to avoid the possibility of aliasing.

If you are starting with a baseband signal that is a square wave, it will have a complex spectrum with many harmonics which will extend way up to the sampling frequency. If you sample it without some pre-filtering (Nyquist filtering) then you will get aliasing. Start with a sinewave at baseband and then a low-pass filtered squarewave. This should then start to make sense.

Sometimes - or even always - it is better to invest in some basic theory before launching into simulations. Maths has no 'common sense' and only does exactly what you have told it to do! Numerical analysis can be even worse.

Thank you for your reply, sophie.

All that you said, I am very familiar with. Why aliasing happens etc. The question had hard base with understanding Discrete Fourier transform.

Assistant explained it to us today, why do we see all those little components even though a square wave has only non-even harmonics.

Turns out that this happens:

http://pokit.org/get/a239350497d574772f569e47b4bbc8e9.jpg

This only happens if the frequency is just right, sometimes they overlap perfectly and we get all uneven.

I will study this further and tell you the results.

Although the theory it self is very important, and we can't live without the basics, sometimes a view from a another angle helps you see things others wouldn't normally. I am determined to pursue my BSc in studying just signals, because they are fun and a lot of things from around you can be explained with them.
 
Last edited by a moderator:
  • #10
that's what makes digital oscilloscopes frustrating.

i think Mother Nature is analog.
 
  • #11
jim hardy said:
that's what makes digital oscilloscopes frustrating.

i think Mother Nature is analog.

Not once I found myself laying around and thinking how would computers look like if we made them work with analog signals.

But still, Planks Length? Constant? Its sad that our universe is discrete...
 
  • #12
Hello, Bass and congrats on your random award - you deserve it.

A few thoughts, extending your Fourier game.

Firstly distortion is any unwanted signal that was not present in the input, but appears in the output.

It used to be taught (wrongly) that any difference could be represented by Fourier analysis.

This is not true.

I suggest you look up

Intermodulation Distortion (first cousin to the aliasing Sophie C mentioned)

Transient Intermodulation Distortion

Slew Rate Limiting.

Further is is again often (wrongly) taught that an infinite Fourier series will add up to a perfect square wave.

Again this is not true.

Here I suggest you look up Gibbs Phenomenon.

go well
 
  • #13
Studiot said:
Hello, Bass and congrats on your random award - you deserve it.

A few thoughts, extending your Fourier game.

Firstly distortion is any unwanted signal that was not present in the input, but appears in the output.

It used to be taught (wrongly) that any difference could be represented by Fourier analysis.

This is not true.

I suggest you look up

Intermodulation Distortion (first cousin to the aliasing Sophie C mentioned)

Transient Intermodulation Distortion

Slew Rate Limiting.

Further is is again often (wrongly) taught that an infinite Fourier series will add up to a perfect square wave.

Again this is not true.

Here I suggest you look up Gibbs Phenomenon.

go well


Thank you. I will do that. I am building this image of how signals and systems work, and each day I learn something new. This slew rate, I saw that somewhere at op amps, but it was too advanced for me to understand at the point I saw it.

Transient intermodulation. Hmm can I take a wild guess?

I've learned that there exists something called passband. Is overlapping of these passband, transient intermodulation? (This is strictly out of my intuition, probably wrong)
 
  • #14
Studiot said:
Hello, Bass and congrats on your random award - you deserve it.

A few thoughts, extending your Fourier game.

Firstly distortion is any unwanted signal that was not present in the input, but appears in the output.

It used to be taught (wrongly) that any difference could be represented by Fourier analysis.

This is not true.

I suggest you look up

Is this anything more than yet another example where the use of discontinuities in a mathematical treatment of a physical situation gives a non-physical / practical outcome? This is another reason to treat the bare results of Matlab etc with respect, if not suspicion, I think. Suitable pre-filtering of a signal, before modulation / analysis / sampling etc. is an essential consideration.
 
  • #15
Bassalisk said:
Not once I found myself laying around and thinking how would computers look like if we made them work with analog signals.

But still, Planks Length? Constant? Its sad that our universe is discrete...

ahhh,, one of my old musings too.

i wondered , what if somebody had followed Bool and developed a base three algebra?

There's no reason to limit logic to simply two states, why not use three - "TRUE" (1), "FALSE"(0), and "DON'T CARE"(indeterminate). We already have tri-state buffers so the hardware is already here. Base 3 computing will simplify artificial intelligence because it mimics human logic - yes, no, maybe...

Well now, once we exceed two logic levels it's only natural to push onward to an infinite number of them , and voila - we're back to the analog computer of the 1940's only with better electronic integrators.

Do they still teach analog computers? That was my favorite lab and in early 60's the fastest electronic way to solve differential equations.

So is the universe really discrete? I say it's just as with Heisenberg's principle of indeterminacy - there's doubtless shorter distances than Planck length just you can't measure them..

old jim
 
  • #16
jim hardy said:
ahhh,, one of my old musings too.

i wondered , what if somebody had followed Bool and developed a base three algebra?

There's no reason to limit logic to simply two states, why not use three - "TRUE" (1), "FALSE"(0), and "DON'T CARE"(indeterminate). We already have tri-state buffers so the hardware is already here. Base 3 computing will simplify artificial intelligence because it mimics human logic - yes, no, maybe...

Well now, once we exceed two logic levels it's only natural to push onward to an infinite number of them , and voila - we're back to the analog computer of the 1940's only with better electronic integrators.

Do they still teach analog computers? That was my favorite lab and in early 60's the fastest electronic way to solve differential equations.

So is the universe really discrete? I say it's just as with Heisenberg's principle of indeterminacy - there's doubtless shorter distances than Planck length just you can't measure them..

old jim

I am not familiar with courses where they teach analog computers. But yes, that maybe state or "don't care state" would be useful. But I think they couldn't make one at the time. 1 and 0 was a holy grail. And mathematics was worked out for it, quite nicely at the time(I think).
 
  • #17
Binary logic and arithmetic are not 'fundamental, by any means. They were almost an arbitrary choice in modern computers - based on the fact that the circuitry is so convenient. Many logical problems have to be re-arranged before they can be solved just with binary logic - hence the frequent use of 'IF trees" and "Case statements", or equivalent, in computing languages.

Look back to the mid 20th Century and you will see there were many calculating machines based on decimal units and, when you get into a house hallway, there are usually more than just two doors.. . . . In fact, most real life choices are more than binary.
 
  • #18
I know we are wandering, but the purpose of tristate circuitry is simple.

If we have two logic outputs connected to one logic input and one output tries to go low and one high what happens?

Alternatively if a single logic output can only assume high or low and is connected to two logic inputs it will always activate/deactivate both inputs .

Either situation can be avoided by having a don't care (actually high impedance) state that doesn't trigger following inputs or fight with other connected outputs.
 
  • #19
Studiot said:
If we have two logic outputs connected to one logic input and one output tries to go low and one high what happens?

Alternatively if a single logic output can only assume high or low and is connected to two logic inputs it will always activate/deactivate both inputs .

The scenarios you are suggesting are no longer 'Logic' but the resulting output will depend upon the particular technology involved.
 
  • #20
hmmm turns out somebody did it , waaay back when...
google Ternary Computer"...

One of the earliest calculating machines, built by Thomas Fowler entirely from wood in 1840, was a ternary computer. The only modern, electronic ternary computer Setun was built in the late 1950s in the Soviet Union at the Moscow State University by Nikolay Brusentsov, and it had notable advantages over the binary computers which eventually replaced it (such as lower electricity consumption and lower production cost). In 1970 Brusentsov built an enhanced version of the computer, which he called Setun-70.
http://en.wikipedia.org/wiki/Ternary_computer

et al
 

1. What is a Fourier coefficient/transform?

A Fourier coefficient/transform is a mathematical tool used to decompose a function into its constituent frequencies. It allows us to represent a complex function as a combination of simpler functions, making it easier to analyze and manipulate.

2. How is a Fourier coefficient/transform used in game development?

In game development, a Fourier coefficient/transform can be used to generate realistic sound effects and animations. It can also be used to improve the visual and audio quality of a game by smoothing out jagged edges and reducing noise.

3. What is the difference between a discrete Fourier transform and a fast Fourier transform?

A discrete Fourier transform (DFT) is a mathematical calculation that converts a signal from its original domain (usually time or space) to a representation in the frequency domain. A fast Fourier transform (FFT) is a specific algorithm for computing the DFT, making it more efficient and faster to compute.

4. Can a Fourier coefficient/transform be applied to any type of signal?

Yes, a Fourier coefficient/transform can be applied to any type of signal, including audio, images, and even text. However, the resulting coefficients may have different interpretations depending on the type of signal being analyzed.

5. Are there any limitations to using a Fourier coefficient/transform in game development?

There are some limitations to using a Fourier coefficient/transform in game development. One limitation is that it may not accurately represent signals with sudden changes or discontinuities. Additionally, it may not be suitable for real-time applications as it requires significant computational power.

Similar threads

  • Electrical Engineering
Replies
4
Views
794
  • Electrical Engineering
Replies
2
Views
1K
  • Electrical Engineering
Replies
5
Views
2K
Replies
2
Views
1K
Replies
31
Views
3K
  • Art, Music, History, and Linguistics
Replies
18
Views
2K
  • Electrical Engineering
Replies
3
Views
1K
  • Electrical Engineering
Replies
3
Views
1K
  • Electrical Engineering
Replies
31
Views
9K
  • Electrical Engineering
2
Replies
45
Views
6K
Back
Top