Plotting of FFT graph in Excel

Digital Signal Processing using computers.

Plotting of FFT graph in Excel

Postby sulphox » Wed Dec 07, 2005 6:58 am

Hi all,

I wanna plot a FFT graph.
Let's say i have
variable, t
y(t)=rect(t)
Y(f)=FFT of rect(t)

If i wanna plot the FFT graph.
What should be the x and the y axis?
is it 't' and 'absolute of Y(f)' respectively?

Please correct me if i'm wrong.

Thanks for any help in advance.[/list]
sulphox
 
Posts: 9
Joined: Wed Dec 07, 2005 6:47 am

Re: Plotting of FFT graph in Excel

Postby William C Bonner » Wed Dec 07, 2005 5:16 pm

I few years back I wrote an excel add in that allowed me to do FFTs
directly on a spreadsheet using array formulae. It still works with
the current version of Excel.

The package was called HRIXL but I do not believe that you can get it
any more.

The Demo has the first column being the position numbers, from 1 to
201.

The Second column is random data created with
=SIN(A:A*60*PI()/201)+RAND()-0.5

The third column is all zeros.

Column E and F are created with the formula =cplxFourier(B1:C201,FALSE)

Column H is created with the formula =SQRT(E1:E201^2+F1:F201^2)

So, Column H is the absolute value of the complex data, that is split
between columns E and F. I plot the data in Column B and Column H in
different graphs to show the original data and the FFT Data.

sulphox wrote:
I wanna plot a FFT graph.
Let's say i have
variable, t
y(t)=rect(t)
Y(f)=FFT of rect(t)

If i wanna plot the FFT graph.
What should be the x and the y axis?
is it 't' and 'absolute of Y(f)' respectively?
William C Bonner
 

Re: Plotting of FFT graph in Excel

Postby Guest » Wed Dec 07, 2005 5:16 pm

On Wed, 07 Dec 2005 03:16:07 -0600,
sulphox77@hotmail-dot-com.no-spam.invalid (sulphox) wrote:
I wanna plot a FFT graph.
Let's say i have
variable, t
y(t)=rect(t)
Y(f)=FFT of rect(t)
If i wanna plot the FFT graph.
What should be the x and the y axis?
is it 't' and 'absolute of Y(f)' respectively?
Please correct me if i'm wrong.
Thanks for any help in advance.

1) You have to have the Analysis ToolPak enabled in Add-Ins to use the

menu Tools/Data Analysis;
Then you can select "Fourier Analysis"

2) The output from "Fourier Analysis" is a column complex data.
To plot othe absolute value, you have to use "IMABS"

3) if your independent variable is time: assuming a fixed interval DT
and a total number of data points N, then you can creat a NEW
column (Freq) where DF = 1/(N*DT) and
Freq(i) = i*DF from 0 to (N-1)

example, sampling period 0.001 seconds with 1000 samples for
a total time of 1 second from 0 to 0.999, then
N*DT = 1 and DF = 1/1=1.

Note that you don't have to plot ALL of the Fourier data since
it will be symmetric about the point( N/2*DF)
Guest
 

Re: Plotting of FFT graph in Excel

Postby Fred Marshall » Thu Dec 08, 2005 12:19 am

"sulphox" <sulphox77@hotmail-dot-com.no-spam.invalid> wrote in message
news:7tqdnWsu2fDKNQveRVn_vA@giganews.com...
Hi all,

I wanna plot a FFT graph.
Let's say i have
variable, t
y(t)=rect(t)
Y(f)=FFT of rect(t)

If i wanna plot the FFT graph.
What should be the x and the y axis?
is it 't' and 'absolute of Y(f)' respectively?

Please correct me if i'm wrong.

Thanks for any help in advance.

There are various FFT outputs that are possible.
The most common goes from radian frequency=0 to radian frequency=2*pi or
frequency=1Hz for an assumed or normalized sample interval of "1" or 1
second.
For real functions being transformed, the magnitude repeats / mirrors at pi
radians/sec or 0.5Hz, so you may not want to plot the result beyond this.
x would be frequency in radians per second or Hz from 0>pi or 0>0.5 ... half
of the output points plus one.
y would be absY(f) where Y(f) is a complex sequence.

Since you're wanting to use Excel, check out:
http://www.fysik.uu.se/kurser/fy660/compendium/Signal/

Fred
Fred Marshall
 

Re: Plotting of FFT graph in Excel

Postby sulphox » Thu Dec 08, 2005 8:25 am

Hi,

First of all, thanks for all the help given.

I would like to ask guest regarding the point no. 3.
I do not understand about the new frequency part.

If i have variable t=-1. -0.9, -08,...., 1 (64 sets of data in total)
I have computed:
The signal, y(t)=rect(t)
The Fourier analysis of y(t), Y(f)
The IMABS of Y(f)

How do I create the new column for the frequency from the data that i have?

Sulphox
sulphox
 
Posts: 9
Joined: Wed Dec 07, 2005 6:47 am

Re: Plotting of FFT graph in Excel

Postby BobM » Thu Dec 08, 2005 11:46 pm

sulphox wrote:
If i have variable t=-1. -0.9, -08,...., 1 (64 sets of data in total)
I have computed:
The signal, y(t)=rect(t)
The Fourier analysis of y(t), Y(f)
The IMABS of Y(f)

How do I create the new column for the frequency from the data that i
have?

The frequency axis will be dependent on the sampling rate, so you need
to determine that first. In general, the frequency column items can be
found with this formula:

F(i) = i*(sampling_rate / FFTsize)

where:
FFTsize = 64
i = each FFT array index (0 ... 63)
sampling_rate = (need to find, in Hz)

Remember, sampling rate is the inverse of the sampling period:

sampling_rate = 1/sampling_period

Find the sampling period (in seconds) and then you can determine the
sampling rate (in Hz).

The sampling period can be determined from your time axis data. That
is, subtract one time axis item from the previous one. For example, if
t = {-1, -.9, -.8, ...} seconds then your sampling period is [(-.9) -
(-1)] = .1 seconds.

Like others said, you only need to plot frequency data from 0 (DC) to
FFTsize/2 (Nyquist). That is, from 0 to 32.

Bob
BobM
 

Re: Plotting of FFT graph in Excel

Postby Glennaebad » Fri Dec 09, 2005 1:16 am

"sulphox" <sulphox77@hotmail-dot-com.no-spam.invalid> wrote in message
news:7tqdnWsu2fDKNQveRVn_vA@giganews.com...
Hi all,

I wanna plot a FFT graph.
Let's say i have
variable, t
y(t)=rect(t)
Y(f)=FFT of rect(t)

If i wanna plot the FFT graph.
What should be the x and the y axis?
is it 't' and 'absolute of Y(f)' respectively?

Please correct me if i'm wrong.

Thanks for any help in advance.

Does anybody use spread sheets except accountants and the like? I neevr used

them and hate the bloody things.

Glen
Glennaebad
 

re:Plotting of FFT graph in Excel

Postby sulphox » Sun Dec 11, 2005 3:32 pm

Hi all,

I'm really sorry i still do not get what you guys mean?


t y(t)=rect(t)
-1 0
-0.9 0
-0.8 0
-0.7 0
-0.6 0
-0.5 1
-0.4 1
-0.3 1
-0.2 1
-0.1 1
0 1
0.1 1
0.2 1
0.3 1
0.4 1
0.5 1
0.6 0
0.7 0
0.8 0
0.9 0
1 0

I'm sorry the data look messy,
Those in bold are y(t) and its values.
The other one not in bold is 't' and its values.

I've computed the FFT of y(t) as well as its ABS and ARG.
In this case, my sampling period is 0.1 and the sampling rate is 1/0.1
How about the FFT size? is it 21?
Is the 'i' is the integer values from 0 to 20?
If the FFT size is 21, then i have to Plot the Frequency data from 0 to 10.5?

Sorry for my poor understanding of the concept.
Please be patience with me.
sulphox
 
Posts: 9
Joined: Wed Dec 07, 2005 6:47 am

Re: re:Plotting of FFT graph in Excel

Postby Fred Marshall » Mon Dec 12, 2005 1:15 am

"sulphox" <sulphox77@hotmail-dot-com.no-spam.invalid> wrote in message
news:XfidnXmsTpdcwwHeRVn_vQ@giganews.com...
Hi all,

I'm really sorry i still do not get what you guys mean?


t y(t)=rect(t)
-1 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
-0.9 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
-0.8 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
-0.7 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
-0.6 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
-0.5 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
-0.4 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
-0.3 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
-0.2 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
-0.1 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0.1 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0.2 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0.3 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0.4 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0.5 [b:ea1a4b00e0]1[/b:ea1a4b00e0]
0.6 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
0.7 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
0.8 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
0.9 [b:ea1a4b00e0]0[/b:ea1a4b00e0]
1 [b:ea1a4b00e0]0[/b:ea1a4b00e0]

I'm sorry the data look messy,
Those in bold are y(t) and its values.

***Well, that's interesting but what the heck is the notation you're using?
"b:"? ; "]0["? etc. It looks like hexadecimal but the brackets,
intervening 1's and 0's and /'s are confusing. Since you said "bold" I
assume that this is some markup language with the b: and /b:, etc.......
But, I can't decipher it. Post in plain text please.

The other one not in bold is 't' and its values.

I've computed the FFT of y(t) as well as its ABS and ARG.
In this case, my sampling period is 0.1 and the sampling rate is
1/0.1
How about the FFT size? is it 21?
Is the 'i' is the integer values from 0 to 20?
If the FFT size is 21, then i have to Plot the Frequency data from 0
to 10.5?

Sorry for my poor understanding of the concept.
Please be patience with me.

See the comment inserted above....

Well, a lot of what you're asking is dependent on what tools you're using.
So, *in general*:

The sequence or array or vector size or length is obviously 21.
You need a special FFT to transform an array that's not of length 2^N.
That's not to say that many of the programs won't do a Discrete Fourier
Transform on a length 21 sequence but it may or may not be "fast" as in
FastFourierTransform=FFT.

The resulting transform will be the same length as the input.
The result will be complex.

You ask what is "i" but give no reference or example... except you ask about
"integer". Do you mean the index of the values? Generally, yes, if the
samples are assumed to be spaced at intervals of 1 second, then the sample
rate is 1Hz or 2*pi radians per second.
Since there are 21 data points, then the frequency resolution in the
transform is fs/N or 1/21Hz.
In your case, fs=10Hz and the spacing of the frequency samples is 10/21 Hz.
The output of the transform starts at 0 and ends at fs-fs/N = fs(1-1/N) Hz
The transform repeats at fs so the value at fs (which is not in the
transformed sequence) will be the same as the value at 0.

What do you need to plot?
If I interpret your question a bit, often what one is interested in is the
data from 0 to fs/2.
In your case, fs/2 = 5
There are 21 samples (not including fs) and 21 intervals between 0 and fs.
Since N is odd, fs/2 falls in the middle of the middle (the 1+N/2) interval.
Thus, there is no sample at fs/2.

f = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 all times
10/21

sample = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 (22)

The frequency at the 11th sample is 10*10/21 which is just below fs/2=5.
So, you need 11 of the 21 samples to almost reach fs/2 .. that is: (N+1)/2
samples.
If the number of samples were even, then you need 1 + N/2 samples which will
include fs/2.

The magnitude of the 12th sample will be the same as the 11th.
The magnitude of the 13th sample will be the same as the 10th ... and so
forth.
That's why you may not be interested in the magnitude data above fs/2 - it's
just a mirror image of the data below fs/2.

I hope this helps.

Fred
Fred Marshall
 

re:Plotting of FFT graph in Excel

Postby sulphox » Wed Dec 14, 2005 4:18 am

Hi Fred,


I tried to work out the Frequency and plotted out the FFT graph.
The graph seems correct.
Thanks for your help.

Thanks to the others as well :D

Sulphox
sulphox
 
Posts: 9
Joined: Wed Dec 07, 2005 6:47 am

re:Plotting of FFT graph in Excel

Postby sulphox » Wed Dec 14, 2005 9:01 am

Hi all, I'm sorry to bother you guys again.

Is the formula, f(i) = i*(sampling_rate / FFTsize)
applicable to all the different type of input signal?

or it only applicable when rect(t) is the input signal?

I tried to apply the formula on another mathematical function.i.e. sinc(x)
after that, i plotted f(i) vs ABS of Y(f) using the same method.

The shape graph is like an inverted rect(t).
Is this the correct graph's that i should get?
i have a feeling i got the wrong graph.

Please advise me.
Thank you.


Sulphox
sulphox
 
Posts: 9
Joined: Wed Dec 07, 2005 6:47 am

Re: re:Plotting of FFT graph in Excel

Postby BobM » Thu Dec 15, 2005 11:51 pm

sulphox wrote:
Hi all, I'm sorry to bother you guys again.

Is the formula, f(i) = i*(sampling_rate / FFTsize)
applicable to all the different type of input signal?

or it only applicable when rect(t) is the input signal?

That formula is applicable to an FFT (or DFT) of any input signal. It's
just for labeling the x-axis (frequency axis).

I tried to apply the formula on another mathematical function.i.e.
sinc(x)
after that, i plotted f(i) vs ABS of Y(f) using the same method.

The shape graph is like an inverted rect(t).
Is this the correct graph's that i should get?
i have a feeling i got the wrong graph.

You got the right graph. The FFT of a sinc() function is a rect()
function. It looks like an inverted rect() when you plot the FFT from
Y[i]...Y[FFTsize-1].

But the items above FFTsize/2 are the negative frequencies, so try
rearranging to plot it like this:

Y[FFTsize/2+1]
....
Y[FFTsize-1]
Y[0]
....
Y[FFTsize/2]

For example, if your FFTsize was 8, it would be re-arranged like this:
Y[5]
Y[6]
Y[7]
Y[0]: DC
Y[1]
Y[2]
Y[3]
Y[4]: Nyquist

Note that it now looks like a normal (non-inverted) rect() function.

For a real input (one with 0 for the imaginary part, such as a sinc()
function), you only need to look at the positive frequencies. Try
plotting it like this:

Y[0]: DC
Y[...]
Y[FFTsize/2]: Nyquist

Now you can see that it's a lowpass filter. This is likely the purpose
of the exercise - to demonstrate that a sinc() function in the time
domain is an ideal lowpass filter in the frequency domain.

However, it takes an infinitely long sinc() function to make an ideal
lowpass filter. Read up on the windowed sinc FIR filter to learn about
a method used to overcome this limitation in practical applications.

Bob
BobM
 

re:Plotting of FFT graph in Excel

Postby sulphox » Sun Dec 18, 2005 4:28 am

I see.

Thanks for your help Bob.

By the way, Merry Christmas to all :D

Sulphox
sulphox
 
Posts: 9
Joined: Wed Dec 07, 2005 6:47 am


Return to DSP

Who is online

Users browsing this forum: No registered users and 0 guests

cron