HydrogenAudio

Hydrogenaudio Forum => Scientific Discussion => Topic started by: adamdea on 2013-09-13 19:07:18

Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-13 19:07:18
I have been trying using considerable persistence and somewhat limited mathematics to grasp some aspects of sampling over the last couple of years. I have tried using a number of textbooks including Pohlamnn and Watkinsons books on Digital audio, Jim lesurf's Information and Measurement and most recently Oppenheim & Wislky's Signals and Systems  (as well as AO's rather good MIT lectures from the internet and a rather good series of lecture slides from Imperial College)

I think I have just about got my mind round the idea that the Fourier transform of an impulse train  in the time domain at time intervals of T is an impulse train in the frequency domain at intervals =2 pi/T
illustrated in slide 10 of this
http://www.ee.ic.ac.uk/pcheung/teaching/ee...20Transform.pdf (http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/Lecture%2010%20-%20Fourier%20Transform.pdf)

and that sampling an arbitrary signal is equivalent to convolving its spectrum with the spectrum of the impulse train which will yield  a spectrum identical with that of the arbtirary signal but repeated at an interval equal to the sampling frequency
http://www.ee.ic.ac.uk/pcheung/teaching/ee...e%20signals.pdf (http://www.ee.ic.ac.uk/pcheung/teaching/ee2_signals/Lecture%2013%20-%20Sampling%20&%20discrete%20signals.pdf)
slide 5

so that provided that the spectrum of the arbitrary signal is band limited to less than half the sample rate, the repeated spectra of the sampled arbitrary signal will not overlap such that the orginal spectrum can be isolated by a rectangular function in the frequency domain/sinc function in the time domain. (ibid slides 6, 16)

So far so good. Where my brain freezes, and i have not really found anything really to help, is with the fact that all real-world sampling is of finite duration (whether or not the thing we wish to sample is). I (sort of) get that any time limited signal cannot be band limited  but I have a more basic confusion about what the spectrum of a time limited signal is.

Shannon say (rather blithely it seems to me) that a time limited signal should be regarded as being represented by a signal which has non zero values in a particular interval and zero values outside the interval and that the sample train can be regarded therefore be regarded as being non zero in that interval and zero outside that interval.  Does this somehow solve the problem that we have only sampled for a limited time.

I find this hugely confusing. Clearly we simply don't know what the signal is outside the period during which we sampled, it could be a period within a song, or there could have been silence before or since.
Jim Lesurf considers the sampling theorem by positing that the  arbitrary signal was a repeating signal on the interval in which he sampled, so that it could be represented by a Fourier series. The spectrum of that fourier series is a set of discrete impulses at an interval equal to the reciprocal of the duration of the time limited signal/sampling interval. If the signal is band limited then there only a finite number of these frequencies . I think Jim lesurf's point is that this shows that the spectrum of a band limited signal contains only a finite number of pieces of information coincides with the number of samples. (band limited and time limited ....hmmm)
http://www.st-andrews.ac.uk/~www_pa/Scots_...f/chapter07.pdf (http://www.st-andrews.ac.uk/~www_pa/Scots_Guide/iandm/pdf/chapter07.pdf) p. 57

Either way the repeating signa which Jim lesurf posits (same sample values outside time limit) is different from the time limited signal which Shannon posits (zero outside time limit). One is a continuous spectrum and the other is a series of discrete frequencies.

This takes me back to the question what is the frequency spectrum of a signal about which we only know anything during a particular window of time ? Is the answer that it is radically uncertain ie it simply cannot be said whether it is Jim lesurf's series of discrete frequencies or whether it is a continuous spectrum?

I tried along the way to see if one could analyse this out instead by trying to work out the spectrum of a series of impulses which did not continue for an infinite time. I know that the spectrum of a single impulse is a complete spectrum. But what is the fourier transform of two impulses. In other words I was trying to approach this by using the same approach used to look at the sampling theorem, but this time using a finite series of impulses to see the result that has when convolved with an arbitrary spectrum.

Can anyone help with my question about the Fourier transform of a finite series of impulses and/or with the wider question of how we prove that the time limited signal is perfectly recorded by an reconstitutable from a finite number of samples. Be gentle I really am trying hard.

Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-13 19:35:07
This takes me back to the question what is the frequency spectrum of a signal about which we only know anything during a particular window of time ?


The spectrum of a signal simply whatever the Fourier transform says it is (assuming the transform exists of course).  If you want to compute it for a particular signal, evaluate the Fourier transform and see what the answer is.

Edit:

So far so good. Where my brain freezes, and i have not really found anything really to help, is with the fact that all real-world sampling is of finite duration (whether or not the thing we wish to sample is). I (sort of) get that any time limited signal cannot be band limited but I have a more basic confusion about what the spectrum of a time limited signal is.


Evaluate the integral, and you get the transform.  I think though what you really want to know is what happens if you take well known infinite functions (e.g. sin(x)) and transform them over a finite window.  In this case the window (say rect(x)) is multiplies by the function in the time domain, which means they're convolved in the frequency domain.  The result is that your delta function becomes a sinc function with width determined by the length of the window over which you sampled.
Title: Sampling of time-limited signals
Post by: Alexey Lukin on 2013-09-13 22:28:09
Where my brain freezes, and i have not really found anything really to help, is with the fact that all real-world sampling is of finite duration (whether or not the thing we wish to sample is). I (sort of) get that any time limited signal cannot be band limited  but I have a more basic confusion about what the spectrum of a time limited signal is.

The word “spectrum” may have different meanings depending on a context. For example, when speaking of continuous signals of infinite duration, or about a Nyquist theorem, “spectrum” usually means a Fourier integral. You are right: if the signal has finite duration, its spectrum is infinite. Such signals do not satisfy the bandlimited condition of a Nyquist theorem and cannot be precisely reconstructed from their digital representation. However it is important to understand that the margins of this error can be made arbitrarily small using sufficient antialiasing and reconstruction filters.


Can anyone help with my question about the Fourier transform of a finite series of impulses and/or with the wider question of how we prove that the time limited signal is perfectly recorded by an reconstitutable from a finite number of samples.

In practice, A/D conversion always happens on finite-duration signals that are not strictly bandlimited. Prior to ADC, such signals are approximately bandlimited using an antialiasing filter. Since noise is always present and real-world filters do not have infinitely deep stopband attenuation, some aliasing happens during A/D conversion, since Nyquist theorem is not fully satisfied. Careful design of filter+ADC keeps this aliasing within strict limits. In practice, the impulse response of filters in ADC and DAC lasts a few milliseconds. So, there's no difference between sampling an infinitely long signal that is nonzero only on a finite interval and a signal whose support is limited to that interval. Filtering slightly extends this time interval (by a few ms), but, other than that, the results of a finite-length operation of A/D and D/A converters are identical with results of an infinitely long operation.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-14 01:24:27
Evaluate the integral, and you get the transform.  I think though what you really want to know is what happens if you take well known infinite functions (e.g. sin(x)) and transform them over a finite window.  In this case the window (say rect(x)) is multiplies by the function in the time domain, which means they're convolved in the frequency domain.  The result is that your delta function becomes a sinc function with width determined by the length of the window over which you sampled.



Thanks for your help. Just to clarify- are you taking a windowed signal in the time domain transforming that into the frequency domain and then convolving that with the spectrum of an infinite sample train? Or are we windowing the sample train first.

Are you saying that a time limited sample train has a spectrum equal to a sinc function, or that the spectrum of each sample is equal to a sinc function.

I think I understand that a single pulse in the time domain (not at t=0) has a spectrum which is a complex exponential. Preambly a finite series of such pulses will have a spectrum equal to the sum of such exponentials.

Sorry if I am being thick, but I am struggling to see the result ie what the spectrum of the sequence of impulses will look like (although we know what it tends towards as the series becomes infinite.)


Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-14 01:53:14
In practice, A/D conversion always happens on finite-duration signals that are not strictly bandlimited. Prior to ADC, such signals are approximately bandlimited using an antialiasing filter. Since noise is always present and real-world filters do not have infinitely deep stopband attenuation, some aliasing happens during A/D conversion, since Nyquist theorem is not fully satisfied. Careful design of filter+ADC keeps this aliasing within strict limits. In practice, the impulse response of filters in ADC and DAC lasts a few milliseconds. So, there's no difference between sampling an infinitely long signal that is nonzero only on a finite interval and a signal whose support is limited to that interval. Filtering slightly extends this time interval (by a few ms), but, other than that, the results of a finite-length operation of A/D and D/A converters are identical with results of an infinitely long operation.
Thanks
Part of my problem is that I can get my mind round a periodic signal being analyised into frequency components but i struggle to grasp how something composed of frequency components whivh individually correspond with continous sinusoids can manage to be zero outside an interval (orthogonality?).

I accept that my struggles with the correct interpretation of limited time sampling are pretty academic since in practice the reconstruction filter is only considers a few (100s?) of sample values out of the millions in the file so it, rather than the length of sampling, is what limits the accuracy of the reconstruction.
Title: Sampling of time-limited signals
Post by: Woodinville on 2013-09-14 02:24:52
For additional help: Norman Morrison's "Fourier Analysis" (I think that's the title) by Wiley Interscience. I believe it's on print-on-demand.
Title: Sampling of time-limited signals
Post by: Alexey Lukin on 2013-09-14 03:20:25
Part of my problem is that I can get my mind round a periodic signal being analyised into frequency components but i struggle to grasp how something composed of frequency components which individually correspond with continuous sinusoids can manage to be zero outside an interval (orthogonality?).

They cannot! If the spectrum of sinusoids is finite, their sum (i.e. the time-domain signal) cannot be strictly zero outside of an interval. However it can have infinitely decaying oscillations outside of an interval. The more sinusoids you use, the closer the signal gets to zero outside of an interval. But it never reaches an exact zero — only in the limit. This is true for both periodic and nonperiodic case.


I accept that my struggles with the correct interpretation of limited time sampling are pretty academic since in practice the reconstruction filter is only considers a few (100s?) of sample values out of the millions in the file

Usually about 100 samples.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-14 13:41:47
For additional help: Norman Morrison's "Fourier Analysis" (I think that's the title) by Wiley Interscience. I believe it's on print-on-demand.

Thanks. Actually I have purchased that book, conceivably on your recommendation. I am finding it helpful, although frustratingly the accompanying computer illustrations are on a floppy disk running basic in dos. I have no idea how to play it in win 7 or 8.
I am still trying but for some reasons still can't get my mind round what a windowed sample train looks like in the frequency domain. Or more generally for sampling over a limited time. What heading should I be looking under (is this a dft?)
Title: Sampling of time-limited signals
Post by: [JAZ] on 2013-09-14 14:07:37
Use dosbox for the application. (you will probably need to change settings to access the floppy drive, or copy them to some folder accessible from dosbox). Also, i hope you know the basics of changing drive/directory and executing a program.
Title: Sampling of time-limited signals
Post by: Alexey Lukin on 2013-09-15 05:19:23
I am still trying but for some reasons still can't get my mind round what a windowed sample train looks like in the frequency domain. Or more generally for sampling over a limited time.

The spectrum of a sample train is a sample train. If you window the time-domain sample train, its spectrum gets convolved with the spectrum of a window function. For example, if you window the sample train with a Gaissuan, each “peak” (delta function) in its spectrum becomes a Gaussian too. If you window with a rectangular window (i.e. just limit the time interval), each spectral peak becomes a sinc function (and they all add together).
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-15 20:54:07

Use dosbox for the application. (you will probably need to change settings to access the floppy drive, or copy them to some folder accessible from dosbox). Also, i hope you know the basics of changing drive/directory and executing a program.

Thanks- I'll give that a go.
I hope I can remember how to work dos.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-15 21:22:46
I am still trying but for some reasons still can't get my mind round what a windowed sample train looks like in the frequency domain. Or more generally for sampling over a limited time.

The spectrum of a sample train is a sample train. If you window the time-domain sample train, its spectrum gets convolved with the spectrum of a window function. For example, if you window the sample train with a Gaissuan, each “peak” (delta function) in its spectrum becomes a Gaussian too. If you window with a rectangular window (i.e. just limit the time interval), each spectral peak becomes a sinc function (and they all add together).

Thanks- that's very helpful. Presumably if the window is wide the sinc function is compressed so that the sinc/Gaussian is almost indistinguishable from a delta, but if the window is narrow the departure from delta becomes significant and hence the spectrum of the sampled signal is no longer the same as the spectrum of the original signal


Title: Sampling of time-limited signals
Post by: Woodinville on 2013-09-16 03:37:32
For additional help: Norman Morrison's "Fourier Analysis" (I think that's the title) by Wiley Interscience. I believe it's on print-on-demand.

Thanks. Actually I have purchased that book, conceivably on your recommendation. I am finding it helpful, although frustratingly the accompanying computer illustrations are on a floppy disk running basic in dos. I have no idea how to play it in win 7 or 8.
I am still trying but for some reasons still can't get my mind round what a windowed sample train looks like in the frequency domain. Or more generally for sampling over a limited time. What heading should I be looking under (is this a dft?)


Load octave and the signal package from sourceforge. The floppies with the Morrison book should be used for skeet.

Then do this in octave:
---
x=1;

for ii=10:2:20
clear x;

len=2^ii;

x(1:len)=0;
x(100:10:1000)=1;

jj=round( (ii-8)/2));
subplot(6,1,jj);
plot(abs(fft(x)));
done

----
Give it a try.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-16 08:14:02
Load octave and the signal package from sourceforge. The floppies with the Morrison book should be used for skeet.

Then do this in octave:
---
x=1;

for ii=10:2:20
clear x;

len=2^ii;

x(1:len)=0;
x(100:10:1000)=1;

jj=round( (ii-8)/2));
subplot(6,1,jj);
plot(abs(fft(x)));
done

----
Give it a try.

I really appreciate your help. I will try to get this working and will report back.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-16 18:51:32
I hate to say this JJ but i am struggling with Octave.
I have tried entering the code you posted in the command window and I am not getting any response. Is there a way of enterign this as a named program or routine so that I can check this is correct and then run. I have not found the octave manual easy to follow.
Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-16 19:23:55
There's an extra parenthesis in the round call and I believe that the "done" needs to be "end".  Never used octave though so I could be wrong.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-17 12:49:09
There's an extra parenthesis in the round call and I believe that the "done" needs to be "end".  Never used octave though so I could be wrong.

Thanks -you're right about the brackets (I think it needs one more open bracket at the beginning.) It still won't run. Any Octave users able to help with this?
Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-17 19:34:11
What happened when you tried changing the done statement?
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-17 21:04:57
What happened when you tried changing the done statement?

It just did nothing I think ie there were no visible signs of anything happening. I'm such a newb that I end up having to type it all back in each time. I can't seem to save the program, load it and edit it.
It is quite dispiriting.
Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-17 21:13:40
I recommend copy and paste into the prompt to reduce the chance that you have mistyped something. Since octave is an interactive programming language, a lack of output probably means its waiting for you to finish entering a statement.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-18 14:56:57
I recommend copy and paste into the prompt to reduce the chance that you have mistyped something. Since octave is an interactive programming language, a lack of output probably means its waiting for you to finish entering a statement.

I now realise that it is possible to paste into octave (using button at the top left).
I have tried JJ's original which crashes octave.
Also the following, either with the last line as done or end- either of which causes octave to do nothing obvious.

x=1;

for ii=10:2:20
clear x;

len=2^ii;

x(1:len)=0;
x(100:10:1000)=1;

jj=round (((ii-8)/2));
subplot(6,1,jj);
plot(abs(fft(x)));
end
Title: Sampling of time-limited signals
Post by: 2Bdecided on 2013-09-18 16:46:03
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.
Title: Sampling of time-limited signals
Post by: kdo on 2013-09-18 17:03:19
x=1;
for ii=10:2:20
clear x;
len=2^ii;
x(1:len)=0;
x(100:10:1000)=1;
jj=round (((ii-8)/2));
subplot(6,1,jj);
plot(abs(fft(x)));
end

When you copy-paste, did you include (selected with the mouse or whatever) the invisible "carriage return/line feed" symbol after the last word "end"?
If the keyword "end" is not followed by the CR/LF, the program might think the command line is not completed and is awaiting further input.
In any case, try pressing ENTER key after copy-paste.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-19 16:58:43
When you copy-paste, did you include (selected with the mouse or whatever) the invisible "carriage return/line feed" symbol after the last word "end"?
If the keyword "end" is not followed by the CR/LF, the program might think the command line is not completed and is awaiting further input.
In any case, try pressing ENTER key after copy-paste.

Good thinking but I'm afraid that pressing return just moves the cursor down one line.

I have decided to invest in a non-commercial use Mathlab licence. (apparently about $100).
Title: Sampling of time-limited signals
Post by: drewfx on 2013-09-19 17:22:13
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?
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-19 17:22:36
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?

Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-19 17:54:14
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.
Title: Sampling of time-limited signals
Post by: Woodinville on 2013-09-21 08:16: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.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-23 12:33:23
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.
Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-23 12:42:07
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.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-23 12:46:46
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""
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-23 13:34:14
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.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-23 13:48:10
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?)
Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-23 13:59:05
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.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-23 14:06:26
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.
Title: Sampling of time-limited signals
Post by: saratoga on 2013-09-23 15:04:59
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.
Title: Sampling of time-limited signals
Post by: Martel on 2013-09-23 16:41:56
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...
Title: Sampling of time-limited signals
Post by: knutinh on 2013-09-23 19:35:39
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
Title: Sampling of time-limited signals
Post by: julf on 2013-09-23 19:56:07
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.
Title: Sampling of time-limited signals
Post by: adamdea on 2013-09-23 21:02:43
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.
Title: Sampling of time-limited signals
Post by: drewfx on 2013-09-23 23:33:02
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