Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Sampling of time-limited signals (Read 23463 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Sampling of time-limited signals

Reply #25
MATLAB does this...

[attachment=7642:matlabpic.gif]

It takes quite a few seconds to do it. Maybe Octave is busy, rather than waiting? I assume a basic...

figure
plot(1:10)

...plots something on your system?

Cheers,
David.

This is very interesting. I'm not sure what it shows, going back to my query.
It seems to me that on each line the x axis (frequency?) increases in scale by a factor of 4.
There seem to be evenly spaced sinc functions, but on each line the interval between them seems to increase by a factor of 4. I would have expected this to be what happened if the sampling interval in the time domain decreased by a factor of 4 (ie the sample rate increased 4 fold).

Can you help me (JJ?)with what this graph is intended to represent.

I was kind of expecting something that represented the effect of sampling at a constant rate but over a time period of varying length. Having pored over Morrison looking for the answer I have come to the conclusion that as the time interval increases the fourier transform of the sample train tends towards a series of deltas.  This is intuitively obvious because the window ceases to exist; but is this becasue as the length of the rectangle tends to infinity it FT becomes a pulse at f=0?


Sampling of time-limited signals

Reply #26
This is very interesting. I'm not sure what it shows, going back to my query.
It seems to me that on each line the x axis (frequency?) increases in scale by a factor of 4.
There seem to be evenly spaced sinc functions, but on each line the interval between them seems to increase by a factor of 4. I would have expected this to be what happened if the sampling interval in the time domain decreased by a factor of 4 (ie the sample rate increased 4 fold).


These are all done at the same sample rate, however in each case the length the interval sampled is increased by a factor of 4.  This increases the resolution of the transform's points by a factor of 4, hence there are 4 times as many points between each sinc and you can see more clearly the shape of the sinc.

I was kind of expecting something that represented the effect of sampling at a constant rate but over a time period of varying length.


That is in fact what you are looking at, although in each case there are the same number of pulses (100), so extra samples beyond those are zero padded. 

Having pored over Morrison looking for the answer I have come to the conclusion that as the time interval increases the fourier transform of the sample train tends towards a series of deltas.  This is intuitively obvious because the window ceases to exist; but is this because as the length of the rectangle tends to infinity it FT becomes a pulse at f=0?


Thats slightly different than was shown here because this has the same number of pulses and then zero padding, rather than adding more pulses.  But yes, if you add more and more pulses, that is what will happen.  Changing the "1000" in that above code to "len" (so that the number of pulses is proportional to the length) will result in the bottom most plot showing a series of near-perfect delta functions.

Sampling of time-limited signals

Reply #27
Thats slightly different than was shown here because this has the same number of pulses and then zero padding, rather than adding more pulses.  But yes, if you add more and more pulses, that is what will happen.  Changing the "1000" in that above code to "len" (so that the number of pulses is proportional to the length) will result in the bottom most plot showing a series of near-perfect delta functions.


Sorry for the typo (done v. end), I typed it into here on the fly.

And indeed, changing from 100 pulses to a full set of them was where I was headed next.

Which shows how as you get more and more and more length, the bandwidth gets narrower and narrower.

BUT when you have the same length, and a wider analysis, all you see is the same thing, with more detail. NOthing more is learned.
-----
J. D. (jj) Johnston

Sampling of time-limited signals

Reply #28
This is very interesting. I'm not sure what it shows, going back to my query.
It seems to me that on each line the x axis (frequency?) increases in scale by a factor of 4.
There seem to be evenly spaced sinc functions, but on each line the interval between them seems to increase by a factor of 4. I would have expected this to be what happened if the sampling interval in the time domain decreased by a factor of 4 (ie the sample rate increased 4 fold).


These are all done at the same sample rate, however in each case the length the interval sampled is increased by a factor of 4.  This increases the resolution of the transform's points by a factor of 4, hence there are 4 times as many points between each sinc and you can see more clearly the shape of the sinc.

I was kind of expecting something that represented the effect of sampling at a constant rate but over a time period of varying length.


That is in fact what you are looking at, although in each case there are the same number of pulses (100), so extra samples beyond those are zero padded. 

Having pored over Morrison looking for the answer I have come to the conclusion that as the time interval increases the fourier transform of the sample train tends towards a series of deltas.  This is intuitively obvious because the window ceases to exist; but is this because as the length of the rectangle tends to infinity it FT becomes a pulse at f=0?


Thats slightly different than was shown here because this has the same number of pulses and then zero padding, rather than adding more pulses.  But yes, if you add more and more pulses, that is what will happen.  Changing the "1000" in that above code to "len" (so that the number of pulses is proportional to the length) will result in the bottom most plot showing a series of near-perfect delta functions.

Hi JJ, Saratoga- sorry for the delay in replying but i was away for the weekend.
I'm sorry if I am being stupid but I am getting hopelessly confused by what exactly it is that JJ's example shows. I'm sure this is just my ignorance but I can't take in the lesson because I don't understand what I am being shown.

My query was about the effect of windowing a sample train. I'm afraid that I don;t understand what is going on in the example because the gap between the impulses in the frequency domain is changing. I'm afraid that my level of understand is limited to getting that the frequency interval between the impulses in the sample train must be the inversely proportional to the time interval. I'm confused by the fact that the gap between the impulses in the frequency domain is changing. I don't understand how this is consistent with the sample rate being constant. I appreciate that you have referred to there being the same number of pulses followed by zero padding. Do you mean that JJ's example represents a signal of length T samples over interval T and then sampled over a greater and greater interval, ie adding more and more samples, all of which have a value of 0.
This suggests to me that we are not looking at a windowed impulse train but at the result of the impulse train being applied to a particular signal(?)

Sorry if this is irritatingly obtuse, but I would be very grateful if you could help me out by explaining (slightly more slooowly) what it is I am looking at.

 

Sampling of time-limited signals

Reply #29
The gap is actually constant in physical units, just the number of samples is changing (because the length of the window changes).  Remember, longer window = more resolution = more samples = each sample covers a shorter interval.

Sampling of time-limited signals

Reply #30
It works in Octave here (after the corrections noted above).

Perhaps there is an issue with your Octave installation? What do have installed and what is your OS?

I am using win 8 professional. I installed octave 3.6.4. The command prompt says that it is "configured for "i-686-pc-mingw386""

Sampling of time-limited signals

Reply #31
The gap is actually constant in physical units, just the number of samples is changing (because the length of the window changes).  Remember, longer window = more resolution = more samples = each sample covers a shorter interval.

Thanks for the very prompt reply.
Can we just start from the beginning.
If I sample at a constant rate (ie what we traditionally call a sample rate in Hertz or radians per second or something.) Then the sample train will be represented by a series of delta functions ion the time dmain and in the frequency domain also by a series of delta functions which will be at intervals of fs

What I know is that if this takes place in a limited time window then my sample train has to be convolved with the fourier transform of the window function. Thus the series of delta functions becomes a series of sinc functions (I think).

The only version of JJ's octave routine i have so far been able to see has been the one david posted. I have therefore not been able to fiddle with the variables myself.

I am getting the sense that you are telling me that the units on the x axis in some way represent units of resolution. Is that because what we are looking at is an FFT not a fourier trasnform as such?

I was sort of getting towards an idea that if we take a time limited function and model it as though it were periodic on the interval of the time limit then it would have a fourier series with a fundamental frequency based on the time interval, which would effectively mean that the FT would be a series of frequencies at multiples of the fundamental. Is this what you mean by resolution? is this is same as saying that we are sampling the frequency spectrum of the signal.

Does this mean that as soon as we are sampling for a limited time, we have to treat the signal as being periodic.

In any event back to JJ's example is the idea that you are showing that as we sample over a longer period the frequency resolution increases.

However if we are assuming that our result ( a limited number of samples)  instead represents a finite number of non zero samples with zeros stretching on to infinity then we no longer would have a discrete series of freqncies but a spectrum. As the number of zeros increase the peaks and zeros on the sinc function get closer and closer so that we are sampling the spectrum more closely.

Sampling of time-limited signals

Reply #32
Thats slightly different than was shown here because this has the same number of pulses and then zero padding, rather than adding more pulses.  But yes, if you add more and more pulses, that is what will happen.  Changing the "1000" in that above code to "len" (so that the number of pulses is proportional to the length) will result in the bottom most plot showing a series of near-perfect delta functions.


Sorry for the typo (done v. end), I typed it into here on the fly.

And indeed, changing from 100 pulses to a full set of them was where I was headed next.

Which shows how as you get more and more and more length, the bandwidth gets narrower and narrower.

BUT when you have the same length, and a wider analysis, all you see is the same thing, with more detail. NOthing more is learned.

JJ am I right in thinking that what you are saying is
if you have 100 samples and treat these as being part of a set which has 100 non zero values ad lots more zero values then you get a continuous spectrum albeit that you have no more information than if you had assumed that the signal was periodic over the 100 sample interval.

if however you sample over a longer interval (1000 samples) you will genuinely know more of the values of spectrum, albeit that you will only know the values within the discrete portions. This will give you more precision although not as much resolution as if you extended the (100 sample) window beyond the actual samples (say to 10000 samples?)

Sampling of time-limited signals

Reply #33
I think you should figure out how to install octave so you can see for yourself.  The idea of giving you code instead of just telling you the answer is that you can learn more by trying these things and seeing what happens. The octave project probably has install directions or a mailing list you can check.

Sampling of time-limited signals

Reply #34
I think you should figure out how to install octave so you can see for yourself.  The idea of giving you code instead of just telling you the answer is that you can learn more by trying these things and seeing what happens. The octave project probably has install directions or a mailing list you can check.

Fair point. I have a feeling that the problem is something to do with octave opening a graphics window. I can get it to do arithmetic.

Also if I can persuade Mathworks to sell me a licence I will be able to use mathlab.

Sampling of time-limited signals

Reply #35
matlab is quite expensive, and only marginally less slow and buggy.  For that reason I'd probably use octave unless you're going to be spending a lot of time with matlab.

Sampling of time-limited signals

Reply #36
I used Matlab a lot during my college studies (automated system control/cybernetics), the university provided limited license copies to students. It was great. When I later tried doing some PCM wave DSP in Octave, all I got were constant freezes and crashes. This was about 3 years ago. Maybe Octave improved since then but I'm not wasting my time with it again...

Sampling of time-limited signals

Reply #37
I used Matlab a lot during my college studies (automated system control/cybernetics), the university provided limited license copies to students. It was great. When I later tried doing some PCM wave DSP in Octave, all I got were constant freezes and crashes. This was about 3 years ago. Maybe Octave improved since then but I'm not wasting my time with it again...

I believe that a popular open/free alternative to MATLAB is Python with the numPy/Scipy/.. packages.

It is not as syntactically equivalent to MATLAB as Octave, but it seems to be an intuitive matrix/vector package on its own. If you learn it, you will have developed a skill that can be used for many tasks.

The biggest drawback of Python and Octave vs MATLAB according to my own limited experience with the 2 first is the lack of a nice IDE. The ability to insert conditional break-points anywhere, continue prototyping code in the command-line (while breaking), rich plotting tools, lots of feedback in the editor, profiling tools etc makes MATLAB my tool of choice.

-k

Sampling of time-limited signals

Reply #38
I believe that a popular open/free alternative to MATLAB is Python with the numPy/Scipy/.. packages.


There is also another almost-MATLAB-compatible open source package, scilab.

Sampling of time-limited signals

Reply #39
Thanks to all for your comments. I think they will sell me a mathlab home use licence for £60 which I can live with. They are a bit slow though - I have now been accepted (afte 2 emials two phone calls and an online application form) but have to wait 2 business days for an email telling me how to download. It does seem like heavy weather. I have bought a car quicker.

Sampling of time-limited signals

Reply #40
It works in Octave here (after the corrections noted above).

Perhaps there is an issue with your Octave installation? What do have installed and what is your OS?

I am using win 8 professional. I installed octave 3.6.4. The command prompt says that it is "configured for "i-686-pc-mingw386""



OK, I haven't kept up to know the current state of things, but as of a few months ago (3.6.2) there were problems with Octave on Win8. Some have resorted to run it under a Windows XWin server, but as a workaround adding some command line options to the shortcut got it working here:

............\octave.exe -i --line-editing