Not a member?

# Discussion Groups | Comp.DSP | I am new to numerical spectrum calculations....

There are 11 messages in this thread.

You are currently looking at messages 1 to .

Is this discussion worth a thumbs up?

0

# I am new to numerical spectrum calculations.... - brettcooper - 2012-07-08 14:52:00

```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
```
______________________________

# Re: I am new to numerical spectrum calculations.... - Tim Wescott - 2012-07-08 22:04:00

```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).

http://www.wescottdesign.com/articles/Sampling/sampling.pdf

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
```
______________________________

# Re: I am new to numerical spectrum calculations.... - Jerry Avins - 2012-07-09 00:23:00

```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.
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
```
______________________________

# Re: I am new to numerical spectrum calculations.... - Fred Marshall - 2012-07-09 02:24:00

```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
```
______________________________

# Re: I am new to numerical spectrum calculations.... - Fred Marshall - 2012-07-09 02:30:00

```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

```
______________________________

# Re: I am new to numerical spectrum calculations.... - Randy Yates - 2012-07-09 03:34:00

```"brettcooper" <b...@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
```
______________________________

# Re: I am new to numerical spectrum calculations.... - Tim Wescott - 2012-07-09 18:27:00

```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
```
______________________________

# Re: I am new to numerical spectrum calculations.... - Jerry Avins - 2012-07-13 09:58:00

```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.
Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯
```
______________________________

# Re: I am new to numerical spectrum calculations.... - glen herrmannsfeldt - 2012-07-13 16:08:00

```Jerry Avins <j...@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
```
______________________________

# Re: I am new to numerical spectrum calculations.... - mnentwig - 2012-07-13 16:43:00

```>> 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