COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### DC component in FFT Spectrum

• Email
• Follow

```Hi,

I've been trying out spectral analysis using FFT. I've modified one the sample programs given in MATLAB. Here's my code:

Fs = 100;                    % Sampling Frequency
T = 1/Fs;                    % Sample time
L = 400;                     % Length of signal
t = (0:L-1)*T;             % Time vector
x = (7+10*sin(2*pi*15*t));

NFFT = 2^nextpow2(L);     % ***PROBLEM***
fspec = Fs/2*linspace(0,1,NFFT/2+1);
X = fft(x,NFFT)/L;
Xf = 2*abs(X(1:NFFT/2+1));
Xf(1) = Xf(1)/2;                 % Restoring DC component to original value
stem(fspec,Xf);

The program works great! However if I try to increase NFFT, say:

NFFT = 4*2^nextpow2(L);

then the amplitudes in the immediate neighborhood of the DC component will be unusually high, distorting my beautiful spectrum: http://img841.imageshack.us/img841/2807/spectrum.png

These points might be due to the higher frequency resolution. My question is: How do I scale them properly?

I tried halving the first few components:

Xf(1:4) = Xf(1:4)/2;

but I don't think this a good solution. Advice?
```
 0

See related articles to this posting

```On Aug 26, 4:54=A0pm, "Akhil Prem" <ramu.premku...@gmail.com> wrote:
> Hi,
>
> I've been trying out spectral analysis using FFT. I've modified one the s=
ample programs given in MATLAB. Here's my code:
>
> Fs =3D 100; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0% Sampling Frequency
> T =3D 1/Fs; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0% Sample time
> L =3D 400; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 % Length of signal
> t =3D (0:L-1)*T; =A0 =A0 =A0 =A0 =A0 =A0 % Time vector
> x =3D (7+10*sin(2*pi*15*t));
>
> NFFT =3D 2^nextpow2(L); =A0 =A0 % ***PROBLEM***
> fspec =3D Fs/2*linspace(0,1,NFFT/2+1);
> X =3D fft(x,NFFT)/L;
> Xf =3D 2*abs(X(1:NFFT/2+1));
> Xf(1) =3D Xf(1)/2; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 % Restoring DC compone=
nt to original value

The Nyquist component is zero. In general, however,
you also have to include

Xf(end) =3D Xf(end)/2;     % Restoring Nyquist component to original
value

> stem(fspec,Xf);
>
> The program works great! However if I try to increase NFFT, say:
>
> NFFT =3D 4*2^nextpow2(L);
>
> then the amplitudes in the immediate neighborhood of the DC component wil=
l be unusually high, distorting my beautiful spectrum:http://img841.imagesh=
ack.us/img841/2807/spectrum.png
>
> These points might be due to the higher frequency resolution.
> My question is: How do I scale them properly?
>
> I tried halving the first few components:
>
> Xf(1:4) =3D Xf(1:4)/2;
>
> but I don't think this a good solution. Advice?

the fft is linear

x1 =3D 7*ones(1,L);
x2 =3D 10*sin(2*pi*15*t));
for NFFT =3D [L, 2^nextpow2(L),  4*2^nextpow2(L) ]
X1 =3D fft(x1,NFFT)/L;
X2 =3D fft(x2,NFFT)/L;
X  =3D X1+X2;
etc % Compare the spectra of X1,X2 and X
end
Now, YOU decide what to do.

Hope this helps.

Greg
```
 0
Reply heath (3990) 8/27/2010 12:21:09 AM

```On Aug 26, 1:54=A0pm, "Akhil Prem" <ramu.premku...@gmail.com> wrote:
> Hi,
>
> I've been trying out spectral analysis using FFT. I've modified one the s=
ample programs given in MATLAB. Here's my code:
> ...

>
> The program works great! However if I try to increase NFFT, say:
>
> NFFT =3D 4*2^nextpow2(L);
>
> then the amplitudes in the immediate neighborhood of the DC component wil=
l be unusually high, distorting my beautiful spectrum:http://img841.imagesh=
ack.us/img841/2807/spectrum.png
>
> These points might be due to the higher frequency resolution. My question=
is: How do I scale them properly?
> ...

These new points are scaled correctly. Your first L point fft just
didn't generate samples at those frequencies.

When you generate a finite set of (L) samples of a sum of tones, the
frequency response is the frequency response of the tones convolved
with the frequency response of the (in this case rectangular) window
which is a sinc function. When the window is L points long, you
calculate an L point fft, and the tones are bin centered in that fft,
the sync functions have zeros at all output samples except the
positions of the tones. Calculate larger and larger ffts and you
sample more and more non-zero points on the frequency response of the
windowed sum of tones. If you try L points and 2*L points you will
generate, first all the possible zero samples and non-zero samples at
tones and second all those samples plus all the non-zero samples
halfway in between the first samples.

Your code is correct, learn to understand what it means.

Dale B. Dalrymple

```
 0

```dbd <dbd@ieee.org> wrote in message <d595b3c8-ef90-4d3b-b85d-0a01113b1728@p12g2000prn.googlegroups.com>...
> On Aug 26, 1:54 pm, "Akhil Prem" <ramu.premku...@gmail.com> wrote:

> These new points are scaled correctly. Your first L point fft just
> didn't generate samples at those frequencies.
>
> When you generate a finite set of (L) samples of a sum of tones, the
> frequency response is the frequency response of the tones convolved
> with the frequency response of the (in this case rectangular) window
> which is a sinc function. When the window is L points long, you
> calculate an L point fft, and the tones are bin centered in that fft,
> the sync functions have zeros at all output samples except the
> positions of the tones. Calculate larger and larger ffts and you
> sample more and more non-zero points on the frequency response of the
> windowed sum of tones. If you try L points and 2*L points you will
> generate, first all the possible zero samples and non-zero samples at
> tones and second all those samples plus all the non-zero samples
> halfway in between the first samples.
>
>
> Your code is correct, learn to understand what it means.
>
> Dale B. Dalrymple

Thank you Greg and Dale.

First of all, I'm aware of why this is happening - about sinc functions and windows, as you have rightly explained. What I'm looking for is a solid technique to handle these unruly samples despite any value of NFFT I may choose. In other words, is there a relation between frequency resolution and the number of samples to be scaled (halved?) near the DC value.

Greg's solution is interesting, but shouldn't I have knowledge of the DC value beforehand? Maybe mean() would do...
```
 0

```I've fixed it.

I took the fft of the mean of the given signal as Gereg suggested and subtracted it from my fault spectrum. He're the code:

Fs = 100;
T = 1/Fs;                     % Sample time
L = 400;                      % Length of signal
t = (0:L-1)*T;              % Time vector
x = (7+10*sin(2*pi*15*t));
xdc = mean(x)*ones(1,L);

NFFT = 2*2^nextpow2(L);
fspec = Fs/2*linspace(0,1,NFFT/2+1);
X = fft(x,NFFT)/L;
Xdc = fft(xdc,NFFT)/L;
Xf = abs(2*(X(1:NFFT/2+1))-(Xdc(1:NFFT/2+1)));  % FIXED

Thanks for the help.
```
 0

```On Aug 26, 11:44=A0pm, "Akhil Prem" <ramu.premku...@gmail.com> wrote:
> ...
>
> Thank you Greg and Dale.
>
> First of all, I'm aware of why this is happening - about sinc functions a=
nd windows, as you have rightly explained.

If this sentence were true, you wouldn't state the next two sentences.

> What I'm looking for is a solid technique to handle these unruly samples =
despite any value of NFFT I may choose.

Try plotting only the values that are peaks of the periodogram or use
"interpolated fft" or frequency reassignment" algorithms to get more
accurate peak locations than peak picking gives for non-bin-centered
components.

> In other words, is there a relation between frequency resolution and the =
number of samples to be scaled (halved?) near the DC value.
>

Only the DC and Nyquist samples (1 each) may deserve special scaling.

> Greg's solution is interesting, but shouldn't I have knowledge of the DC =
value beforehand? Maybe mean() would do...

Since your spectral components are all bin centered, the DC component
and the mean are the same in either the time or frequency domains.

Dale B. Dalrymple
```
 0

```> Only the DC and Nyquist samples (1 each) may deserve special scaling.

This is where the problem arises. Its NOT just the DC or Nyquist component that needs special scaling if one uses normal fft (without ""interpolated fft" or frequency reassignment" algorithms"). A few components surrounding the DC value need also be scaled. My question was, how do I figure out which all components I should scale.

Anyway, I've found a solution I'm satisfied with. Thanks again.
```
 0

```On Aug 27, 9:59=A0am, "Akhil Prem" <ramu.premku...@gmail.com> wrote:
> > Only the DC and Nyquist samples (1 each) may deserve special scaling.
>
> This is where the problem arises. Its NOT just the DC or Nyquist componen=
t that needs special scaling if one uses normal fft (without ""interpolated=
fft" or frequency reassignment" algorithms"). A few components surrounding=
the DC value need also be scaled. My question was, how do I figure out whi=
ch all components I should scale.

I think you have found the best solution for yourself. When you have
you, the best way to remove the annoyance and confusion is to subtract
that signal component out. If you move from artificial data to real
world sampled data you may need different solutions. Good luck!

>
> Anyway, I've found a solution I'm satisfied with. Thanks again.

The source of your bliss is obvious.

Dale B. Dalrymple
```
 0

```> If you move from artificial data to real
> world sampled data you may need different solutions. Good luck!

This program actually forms a part of a home brewed data acquisition system I'm constructing and it is giving good results with some real world signals I've sampled:

http://img266.imageshack.us/img266/3600/spectrumof555waveforms.png

```
 0

```On Aug 27, 12:59=A0pm, "Akhil Prem" <ramu.premku...@gmail.com> wrote:
> > Only the DC and Nyquist samples (1 each) may deserve special scaling.
>
> This is where the problem arises. Its NOT just the DC or Nyquist componen=
t that needs special scaling if one uses normal fft (without ""interpolated=
fft" or frequency reassignment" algorithms"). A few components surrounding=
the DC value need also be scaled. My question was, how do I figure out whi=
ch all components I should scale.
>
> Anyway, I've found a solution I'm satisfied with. Thanks again.

I'm not sure what your application is. However, the fft,
with appropriate windowing, reveals the frequency content
of your signal. If you fiddle with the spectrum you might get
something that looks pleasing to the eye but the corresponding
frequency content is just a figment of your imagination.

I you don't want sidelobes of a large DC component to
contaminate the rest of the spectrum, subtract the mean
from the time signal instead of fiddling with the spectrum
a posteriori.

Hope this helps.

Greg
```
 0

```> I'm not sure what your application is. However, the fft,
> with appropriate windowing, reveals the frequency content
> of your signal. If you fiddle with the spectrum you might get
> something that looks pleasing to the eye but the corresponding
> frequency content is just a figment of your imagination.

Hmm... you and dale may be right. The problem is that I don't have a standard spectroscope or the  sort to compare my results with. I'll have to investigate more.

> I you don't want sidelobes of a large DC component to
> contaminate the rest of the spectrum, subtract the mean
> from the time signal instead of fiddling with the spectrum
> a posteriori.

But by linearity property, both approaches should yield the same results, shouldn't it? And I do wish to see the DC value in my spectrum also.

Here's another test I conducted; this time I sampled waveforms from an accelerometer. The waveforms are shaking it:

http://img839.imageshack.us/img839/9985/accelerometerxandychann.png

Ultimately, my application boils down to this: I want to select an optimal sampling frequency for sampling an accelerometer signal and I'm trying to analyse its spectrum to that end.
```
 0

```On Aug 28, 10:11=A0am, "Akhil Prem" <ramu.premku...@gmail.com> wrote:
> > I'm not sure what your application is. However, the fft,
> > with appropriate windowing, reveals the frequency content
> > of your signal. If you fiddle with the spectrum you might get
> > something that looks pleasing to the eye but the corresponding
> > frequency content is just a figment of your imagination.
>
> Hmm... you and dale may be right. The problem is that I don't have a stan=
dard spectroscope or the =A0sort to compare my results with. I'll have to i=
nvestigate more.
>
> > I you don't want sidelobes of a large DC component to
> > contaminate the rest of the spectrum, subtract the mean
> > from the time signal instead of fiddling with the spectrum
> > a posteriori.
>
> But by linearity property, both approaches should yield the same results,=
shouldn't it? And I do wish to see the DC value in my spectrum also.
>
> Here's another test I conducted; this time I sampled waveforms from an ac=
celerometer. The waveforms are shaking it:
>
> http://img839.imageshack.us/img839/9985/accelerometerxandychann.png
>
> Ultimately, my application boils down to this: I want to select an optima=
l sampling frequency for sampling an accelerometer signal and I'm trying to=
analyse its spectrum to that end.

Concentrate on

X2 =3D fft(x-mean(x),NFFT)/length(x);

Hope this helps.

Greg
```
 0

11 Replies
430 Views

Similar Articles

12/8/2013 1:14:12 AM
page loaded in 30773 ms. (0)

Similar Artilces:

BUF component
How does a BUF component increase the drive strength of a signal? Thanks Roger schrieb: > How does a BUF component increase the drive strength of a signal? Almost all buffers are two inverters in a chain. The last inverter may have bigger transistors. But even with standard size transistors a buffer is useful: If a weak signal is only capable of driving the first inverter of a buffer, the output inverter will be capable of driving much more gates. The cost for all this: a delay. Ralf Ralf Hildebrandt wrote: > Roger schrieb: > >> How does a BUF component increase the drive strength of a signal? > > Almost all buffers are two inverters in a chain. The last inverter may > have bigger transistors. > > But even with standard size transistors a buffer is useful: If a weak > signal is only capable of driving the first inverter of a buffer, the > output inverter will be capable of driving much more gates. The cost for > all this: a delay. > > Ralf More, If the load is large, a buffer will improve the delay (as it can charge and discharge the capacitive load faster than a weak driver). So, the cost for a buffer is that you may need

Timer Component
Is it possible to add a timer component to the Toolbox? How do I do it? Thanks Geoff Hi, On Fri, 6 Feb 2004 19:45:27 -0000, Geoff wrote: > Is it possible to add a timer component to the Toolbox? How do I do it? there is no timer-control in Access as in VB. But every form has a timer-interval and an event being fired then (check the events-properties-page). Coming from VB, this may be a little irritating (i.e. requiring extra code) if you need more than one timer though. Cheers, Olaf [MVP] -- My .02: www.Resources.IntuiDev.com Forms have a built-in timer property. Peter Russell Geoff previously wrote: > Is it possible to add a timer component to the Toolbox? How do I do it? > > Thanks > > Geoff > > >

Component Monitoring
Hi: Does anyone have such resources where I can look into? I'm investigating on the component monitoring. The papers that I can get on IEEE Software are kind of limited. It seems that only three approaches are currently given for that: 1) testing approach: monitor the behaviors by faults-injection 2) code instrumentation: add the code related to security or trace concerns into the target system 3) Interactions interception: by intercepting the messages exchanged among the components, validate the values. There is no further approach on how to detect the failures like blocking, error propagations, etc. Can anyone point to some more useful tips? Thanks. You can try a tool like apache tcpmon to intercept messages to the server. You can then manually review them. Not sure if it helps, but good luck anyway. -C

Component patterns and assembly peformance
I had read in another post that componnet patterns appear to slow assembly performance and I was curious to see if anyone else is seeing the same problem. Very soon I will need to create quite a few component patterns and I am trying to avoid performance issues when possible. Would dissolving the the pattern and using a fix mate to fix the component in place lead to better performance as compared to having the pattern? The patterns do not have a lot of instances, probably less than 10 for each pattern but there could be a lot of patterns. Maybe up to 100 of them in various assembly documents, probably just one or two per assembly document. Thanks Still testing to determine that. TOP

plotting processor component usage
Hi, I've designed a simple processor that contains several functional units, and I wanted to plot a graph of their utililisation versus time in Excel, but I can't find anything simple in Excel to plot this kind of graph, would anyone know any way to plot it? sample graph: functional units ^ A | op1 | B | op2 | C | op3 op4 ------------------------------------------------> 0 1 2 3 time (CLK) I tried using a stacked bar graph in Excel, but that involves a lo

Principal Component Analysis (PCA)
Hi, I have a set of electrophysiological recordings which consist of multiple spectral components. I would like to separate these signals into their basic components and to be able to tell exactly how many basic components are there in my signals. I have read and reread the documentation regarding PCA in Matlab and have failed to understand how to do this. I would eventually want to use Wavelet PCA since my signals are complex and non-stationary. Am I even in the right direction here? Thanks! Y. On 8 Mar, 10:39, "Yoav Mor" <mor.yoav.nos...@gmail.com> wrote: > Hi, >

dynamic TImage component creation
(C++ Builder 6.0 enterprise) I tried to create a TImage component by using this source code: // --- TImage *Image = new TImage (Application); Image->Picture->LoadFromFile ("a.bmp"); // --- There are no errors, but the image does not apear on the form. I also tried setting properties, like: Left, Top, Height, Width, Visible, but that didn't change anything. Maybe I'm doing something wrong or I'm forgeting to do something. I would be thankful for helping me out. Maciej Bulaszewski, Poland -- Posted via http://dbforums.com "macbul" <member39439@dbforums.com> wrote in message news:3366858.1063475336@dbforums.com... > (C++ Builder 6.0 enterprise) Note: this is out of topic here. Some will flame you for being OT, but most importantly your chances of getting a helpful answer are much slimmer than on a dedicated NG ( i.e. borland...., see their web site). > TImage *Image = new TImage (Application); > > Image->Picture->LoadFromFile ("a.bmp"); .... > There are no errors, but the image does not apear on the form. I also > tried setting properties, like: Left, Top, Height, Width, Visible

Generating Core component
Hello , I was wondering if anyone has any ideas on how I would got about generating a core. I've currently having a problem attaching my nco component to my top level entity, after running the nco by itself , everything seems to work successfully , but after I attach it, i'm experiencing strange behavior and was wondering it the synthesizing stages isn't meeting proper constrains. If generating a core isn't possible , how can I optimize the way the nco is implemented into the design ? Thanks in advance

4 connected component
Hi All, Could some one help me out in solving 4 connected component which has 0100 1001 0100 1001 In which 1 is replaced with a variable which pops up a value or (image) and 0 has no value in it. Need to write matlab code for 4 connected component. There are special function bwconncomp for this in image processing toolbox. Code example: bw0=[0 1 0 0 1 0 0 1 0 1 0 0 1 0 0 1]; bw=logical(bw0); % true/false array CC = bwconncomp(bw,4); % find 4-connected components L = labelmatrix(CC); % labels to make colors RGB = label2rgb(L); % each component has own color %figure, imshow(RGB); imagesc(RGB); ------------------------------------ Maxim Vedenev, Matlab expert vedenev@ngs.ru http://simulations.narod.ru/ "sandeep" wrote in message <k2p2cb\$j5g\$1@newscl01ah.mathworks.com>... > Hi All, > Could some one help me out in solving 4 connected component which has > 0100 > 1001 > 0100 > 1001 > > In which 1 is replaced with a variable which pops up a value or (image) and 0 has no value in it. > > Need to write matlab code for 4 connected component. doc bwconncomp

Olvio.Ecommerce component for Authorize.Net
Olvio IT is proud to present a free component to integrate with the Authorize.Net payment gateway. The component is fully written in C# and works with the Microsoft .Net Framework 1.0 or 1.1. It's available for free at: http://www.olvio.com/WebModules/Products/AuthorizeNet/AuthorizeNet.aspx Regards, Iulian Ionescu Olvio IT, Inc.