DSPRelated.com
Forums

I am new to numerical spectrum calculations....

Started by brettcooper July 8, 2012
I have started working on some numerical simulations with Matlab...
I "realized" that the infinite, continuous range signals are mapped in a
finite range discrete signals.

The continuous frequency F goes from -infinity to + infinity.
The discrete frequency goes from -1/2 to +1/2.
That means the continuous frequency F becomes constrained to have values
between -Fs/2 and Fs/2.  I know we are restricting our attention to the
discrete frequency range [-1/2, 1/2]. Everything else outside this range is
periodic. nothing new. All we need to look for is within  [-1/2, 1/2]. 
But what happens to a continuous sinusoid having frequency F>Fs/2? Does it
get ignored? Or does it information appear the same as a sinusoid having
lower or higher frequency? If so, it means that real information contained
in high frequency sinusoids F>Fs/2 gets lost, correct? 

So if we have an analog signal g(t) having a bandwidth W of continuous
frequencies, once we fix the sampling frequency Fs, we can only properly
represent those continuous frequencies that have a value smaller or equal
to Fs/2. All those other frequencies are not "well represented" and cause
artifacts in the spectrum (aliasing).
The choice of Fs is therefore fundamental. If we knew the bandwidth W a
priori, we could choose Fs to be 2W....
But we often don't know W for an analog signal g(t). We a numerically
trying to find the FT of the signal itself. Sometimes we are given an
analytic expression for g(t), maybe after laborious theoretical
calculations. Its Fourier transform may not be easy to calculate
analytically so we try to do it numerically...

How will we know that our numerical FFT is a good approximation of the
theoretical spectrum? In real life we apply antialiasing filters, etc... to
fix the bandwidth W....But if we are simply doing numerical calculations we
cannot do that or infer that W has a certain value...we could guess a value
that is too small and choose Fs the wrong way...

thanks,
Brett
On Sun, 08 Jul 2012 13:52:40 -0500, brettcooper wrote:

> I have started working on some numerical simulations with Matlab... > I "realized" that the infinite, continuous range signals are mapped in a > finite range discrete signals. > > The continuous frequency F goes from -infinity to + infinity. > The discrete frequency goes from -1/2 to +1/2. > That means the continuous frequency F becomes constrained to have values > between -Fs/2 and Fs/2. I know we are restricting our attention to the > discrete frequency range [-1/2, 1/2]. Everything else outside this range > is periodic. nothing new. All we need to look for is within [-1/2, > 1/2]. > But what happens to a continuous sinusoid having frequency F>Fs/2? Does > it get ignored? Or does it information appear the same as a sinusoid > having lower or higher frequency? If so, it means that real information > contained in high frequency sinusoids F>Fs/2 gets lost, correct? > > So if we have an analog signal g(t) having a bandwidth W of continuous > frequencies, once we fix the sampling frequency Fs, we can only properly > represent those continuous frequencies that have a value smaller or > equal to Fs/2. All those other frequencies are not "well represented" > and cause artifacts in the spectrum (aliasing). > The choice of Fs is therefore fundamental. If we knew the bandwidth W a > priori, we could choose Fs to be 2W.... > But we often don't know W for an analog signal g(t). We a numerically > trying to find the FT of the signal itself. Sometimes we are given an > analytic expression for g(t), maybe after laborious theoretical > calculations. Its Fourier transform may not be easy to calculate > analytically so we try to do it numerically... > > How will we know that our numerical FFT is a good approximation of the > theoretical spectrum? In real life we apply antialiasing filters, etc... > to fix the bandwidth W....But if we are simply doing numerical > calculations we cannot do that or infer that W has a certain value...we > could guess a value that is too small and choose Fs the wrong way... > > thanks, > Brett
If your simulator uses an adaptive time step, figure out what the shortest step is, and use that -- or some multiple of it -- as your sampling rate (after, of course, figuring out how to resample everything at that frequency). This doesn't address your question directly, but it may help: http://www.wescottdesign.com/articles/Sampling/sampling.pdf -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
On 7/8/2012 2:52 PM, brettcooper wrote:
> I have started working on some numerical simulations with Matlab... > I "realized" that the infinite, continuous range signals are mapped in a > finite range discrete signals.
You need to bandlimit the signal to less than fs/2 with a filter before you sample it. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
On 7/8/2012 11:52 AM, brettcooper wrote:
..,..snip....
> But what happens to a continuous sinusoid having frequency F>Fs/2? Does it > get ignored? Or does it information appear the same as a sinusoid having > lower or higher frequency? If so, it means that real information contained > in high frequency sinusoids F>Fs/2 gets lost, correct?
Brett, These are the only questions I found in a rather long post. What happens is that it appears as a sinusoid having a lower frequency within -Fs/2 to Fs/2. Whether that information is "lost" or not depends on more than you've mentioned. Fred
On 7/8/2012 9:23 PM, Jerry Avins wrote:
> On 7/8/2012 2:52 PM, brettcooper wrote: >> I have started working on some numerical simulations with Matlab... >> I "realized" that the infinite, continuous range signals are mapped in a >> finite range discrete signals. > > You need to bandlimit the signal to less than fs/2 with a filter before > you sample it. > > Jerry
Jerry, Maybe it's more accurate to say "you would like to bandlimit the signal to less than Fs/2" (which, of course is impossible) or you would like to know that the sampled signal energy of of little significance above Fs/2. Because as the OP suggests, what if you dont' know to begin with? I would suggest if it's possible: 1) Sample at a high rate and FT. 2) Decide on a lower, reasonable sample rate such that the important parts (i.e. energy) is below Fs/2. 3) Sample at that rate. Fred
"brettcooper" <brett.cooper76@n_o_s_p_a_m.gmail.com> writes:

> I have started working on some numerical simulations with Matlab... > I "realized" that the infinite, continuous range signals are mapped in a > finite range discrete signals. > > The continuous frequency F goes from -infinity to + infinity. > The discrete frequency goes from -1/2 to +1/2. > That means the continuous frequency F becomes constrained to have values > between -Fs/2 and Fs/2. I know we are restricting our attention to the > discrete frequency range [-1/2, 1/2]. Everything else outside this range is > periodic. nothing new. All we need to look for is within [-1/2, 1/2]. > But what happens to a continuous sinusoid having frequency F>Fs/2? Does it > get ignored? Or does it information appear the same as a sinusoid having > lower or higher frequency? If so, it means that real information contained > in high frequency sinusoids F>Fs/2 gets lost, correct? > > So if we have an analog signal g(t) having a bandwidth W of continuous > frequencies, once we fix the sampling frequency Fs, we can only properly > represent those continuous frequencies that have a value smaller or equal > to Fs/2. All those other frequencies are not "well represented" and cause > artifacts in the spectrum (aliasing). > The choice of Fs is therefore fundamental. If we knew the bandwidth W a > priori, we could choose Fs to be 2W.... > But we often don't know W for an analog signal g(t). We a numerically > trying to find the FT of the signal itself. Sometimes we are given an > analytic expression for g(t), maybe after laborious theoretical > calculations. Its Fourier transform may not be easy to calculate > analytically so we try to do it numerically... > > How will we know that our numerical FFT is a good approximation of the > theoretical spectrum? In real life we apply antialiasing filters, etc... to > fix the bandwidth W....But if we are simply doing numerical calculations we > cannot do that or infer that W has a certain value...we could guess a value > that is too small and choose Fs the wrong way...
The answer seems clear: Compute the Fourier transform of the function. As long as the function g(t) satisfies the Dirichlet conditions, it will have a Fourier transform. If it's too hard to calculate by hand, use Maple (or Matlab or Maxima or...). -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
On Mon, 09 Jul 2012 00:23:47 -0400, Jerry Avins wrote:

> On 7/8/2012 2:52 PM, brettcooper wrote: >> I have started working on some numerical simulations with Matlab... I >> "realized" that the infinite, continuous range signals are mapped in a >> finite range discrete signals. > > You need to bandlimit the signal to less than fs/2 with a filter before > you sample it.
Unless, of course, that's going to create more problems than it solves. His life is complicated by the fact that his signal isn't real: it's the output of a simulation program. So he's not at liberty to filter the signal before sampling. If he's patient, though, he could set his minimum time step really low. -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
On 7/9/2012 6:27 PM, Tim Wescott wrote:
> On Mon, 09 Jul 2012 00:23:47 -0400, Jerry Avins wrote: > >> On 7/8/2012 2:52 PM, brettcooper wrote: >>> I have started working on some numerical simulations with Matlab... I >>> "realized" that the infinite, continuous range signals are mapped in a >>> finite range discrete signals. >> >> You need to bandlimit the signal to less than fs/2 with a filter before >> you sample it. > > Unless, of course, that's going to create more problems than it solves. > > His life is complicated by the fact that his signal isn't real: it's the > output of a simulation program. So he's not at liberty to filter the > signal before sampling. > > If he's patient, though, he could set his minimum time step really low.
Freds's restating of what I wrote makes good sense. Are you implying that a signal generated by a simulation can't be filtered? How about using a simulated filter? :-) Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
Jerry Avins <jya@ieee.org> wrote:

(snip, someone wrote)
>>> You need to bandlimit the signal to less than fs/2 with a filter before >>> you sample it.
>> Unless, of course, that's going to create more problems than it solves.
>> His life is complicated by the fact that his signal isn't real: it's the >> output of a simulation program. So he's not at liberty to filter the >> signal before sampling.
>> If he's patient, though, he could set his minimum time step really low.
> Freds's restating of what I wrote makes good sense. Are you implying > that a signal generated by a simulation can't be filtered? How about > using a simulated filter? :-)
Digital simulation should be able to simulate digital filters. Analog simulation, such as SPICE, would be needed for analog filters. I wouldn't want to try analog filters in Matlab. You could also take the simulated data out through a DAC, filter it through an RLC filter, then ADC and send it back to the simulation. -- glen
>> I wouldn't want to try analog filters in Matlab.
It's not as bad as it sounds. The easy way is to take FFT of the whole signal, evaluate the Laplace-domain frequency response at FFT bin frequencies and multiply. The impulse response will wrap around, so it needs some zero padding if your signal isn't cyclic. I can evaluate the continuous-time impulse response on a sampling grid, truncate, and call it an FIR filter. Or if it needs to really accurate, design whatever filter it takes to mimic the continuous-time H(f) in the band of interest. Oh alright. It's not as bad as it sounds. But it sure does sound bad... Anyway, this http://www.dsprelated.com/showcode/210.php is one script I use myself ('componentmodel' examples, use the download link at the bottom for the complete package)