Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fast Fourier Transform

Subject: Fast Fourier Transform

From: kk KKsingh

Date: 28 Feb, 2010 23:54:05

Message: 1 of 4

Although i know with irregular sampling FFT doesnot suppose to give good results. But Can any one can tell me reason for this, in the code below i am taking 6 samples off that is i am missing 11 samples

clear all
close all
N=202; % Number sample points
fo = 10; %frequency of the sine wave
Fs = 100; %sampling rate
Ts = 1/Fs; %sampling time interval
t = 0:Ts:Ts*(N-1); %sampling period
y = 2*sin(2*pi*fo*t);
y1=y;t1=t;

z=[23 45 67 89 90 123 145 148 175 189 192]

y1(z)=[]
t1(z)=[]


f=fftshift(abs(fft(y1)));
N=length(y1);
 kx=-(N-1)/2:(N-1)/2; % N odd
freqaxis1=1/Ts/N*kx;

plot(freqaxis1,f)


My question is when i miss more number of samples, I get shift in the spectrum....My values are not at 10 Hz any more....they keep getting shifted when i increase the number of samples..I will be adding FFT with one of my interpolation technique but i cant do this untill i know the reason for shift and remedy fr this ( other than including zeros)

Thanks

kk

Subject: Fast Fourier Transform

From: nanren888

Date: 7 Mar, 2010 08:09:21

Message: 2 of 4

"kk KKsingh" <akikumar1983@gmail.com> wrote in message <hmevmt$37t$1@fred.mathworks.com>...
> Although i know with irregular sampling FFT doesnot suppose to give good results. But Can any one can tell me reason for this, in the code below i am taking 6 samples off that is i am missing 11 samples
>
> clear all
> close all
> N=202; % Number sample points
> fo = 10; %frequency of the sine wave
> Fs = 100; %sampling rate
> Ts = 1/Fs; %sampling time interval
> t = 0:Ts:Ts*(N-1); %sampling period
> y = 2*sin(2*pi*fo*t);
> y1=y;t1=t;
>
> z=[23 45 67 89 90 123 145 148 175 189 192]
>
> y1(z)=[]
> t1(z)=[]
>
>
> f=fftshift(abs(fft(y1)));
> N=length(y1);
> kx=-(N-1)/2:(N-1)/2; % N odd
> freqaxis1=1/Ts/N*kx;
>
> plot(freqaxis1,f)
>
>
> My question is when i miss more number of samples, I get shift in the spectrum....My values are not at 10 Hz any more....they keep getting shifted when i increase the number of samples..I will be adding FFT with one of my interpolation technique but i cant do this untill i know the reason for shift and remedy fr this ( other than including zeros)
>
> Thanks
>
> kk

Do you have a reference for what you are trying to do?
Is there a pattern to the samples you choose to keep?
If I take random irregular samples from a signal, I would not expect to be able to use the FFT in any simple way.
I know there is oftentimes, no distinction made between the FFT & DFT & "DFT" is used for several different meanings.
With the DFT, that is, individual correlations with complex exponentials, I can calculate components or reconstructions based on any sample or samples I like, always keeping in mind that I will get the reconstruction of what I give it, no more.
With the FFT, there is an assumption of equally-spaces samples in each domain.
So, if I take samples at some other places, then put them into an FFT that assumes that they were equally spaced, I think I have to expect "distortions: in the spectrum.
Do you have some justification for assuming that you can use the FFT at all?

Subject: Fast Fourier Transform

From: Greg Heath

Date: 7 Mar, 2010 18:53:02

Message: 3 of 4

On Feb 28, 6:54 pm, "kk KKsingh" <akikumar1...@gmail.com> wrote:
> Although i know with irregular sampling FFT does
> not suppose to give good results. But Can any one
> can tell me reason for this,

The direct and inverse relations for DFT and IDFT are
special cases of Least Square relationships that are only
valid for uniformly spaced samples.

When the samples are not uniformly spaced they have
to be weighted by the spacing.

> > in the code below i am taking 6 samples off that
> > is i am missing 11 samples
>
> > clear all
> > close all
> > N=202; % Number sample points
> > fo = 10; %frequency of the sine wave
> > Fs = 100; %sampling rate
> > Ts = 1/Fs; %sampling time interval
> > t = 0:Ts:Ts*(N-1); %sampling period
> > y = 2*sin(2*pi*fo*t);
> > y1=y;t1=t;
>
> > z=[23 45 67 89 90 123 145 148 175 189 192]
>
> > y1(z)=[]
> > t1(z)=[]
>
> > f=fftshift(abs(fft(y1)));

Invalid because y samples are not uniformly spaced.

> > N=length(y1);
> > kx=-(N-1)/2:(N-1)/2; % N odd
> > freqaxis1=1/Ts/N*kx;
>
> > plot(freqaxis1,f)
>
> > My question is when i miss more number of samples, I get shift in the spectrum....My values are not at 10 Hz any more....they keep getting shifted when i increase the number of samples..I will be adding FFT with one of my interpolation technique but i cant do this untill i know the reason for shift and remedy fr > > this ( other than including zeros)

Use Least Squares to obtain the spectrum
when the time spacing is nonuniform.
When the time spacing is uniform, Least
Squares reduces to the DFT formula.

Hope this helps.

Greg

Subject: Fast Fourier Transform

From: Matt J

Date: 8 Mar, 2010 02:30:22

Message: 4 of 4

"kk KKsingh" <akikumar1983@gmail.com> wrote in message <hmevmt$37t$1@fred.mathworks.com>...
> Although i know with irregular sampling FFT doesnot suppose to give good results. But Can any one can tell me reason for this,
============

The FFT/DFT is derived by discretizing the continuous Fourier transform at regular sampling intervals dt (time) and df (frequency) under the following contraint

dt*df=1/N %N is number of samples

When instead you discretize irregularly, a different formula is obtained.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us