DSPRelated.com
Forums

Plotting of FFT graph in Excel

Started by sulphox December 7, 2005
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.

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?
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)
"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
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 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
"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
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.
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" <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
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