Skip to main content
1-Visitor
March 16, 2020
Solved

FFT peak amplitude

  • March 16, 2020
  • 3 replies
  • 14534 views

Hello,

In the attached worksheet, the FFT of a function is calculated. I would like to get the amplitude at each of the frequencies from the signal. From the plots of the FFT magnitude at various frequencies, it can be seen that the peaks amplitude decrease with increasing the frequency. The plots also show that sometimes the first peak is larger than the second peak and sometimes it is reversed.

 

I was wondering if this is a natural behavior of FFT or I must modify the script. I greatly appreciate your advice.

 

All the best,

Payman

 

payman_0-1584427661895.png

 

Best answer by LouP

There are a number of different things going on here, and too many complications in the worksheet to let the basic issues show clearly. I didn't change most of the sheet, but I did remove the second delta 1 frequency term, since it just clouds the issue.

 

1. The cases of z= 5 and z=500 show the same symptom: leakage. Due to the spacing of the sampling intervals, integer z does not correspond to integer # of cycles over the full sampling period.I added some functions in rev2 (attached) to calc power and actual bin number. z=5 is centered at bin 4.69, z=500 is centered at bin 469.19. the different fractional spacing explains the difference in spectral component amplitudes - leakage is spread differently.

 

2. When z=0.1 (low) , the actual value of the sampled function is near 0, not 1, since the sampling does not start at zero argument of the cosine, since k has an initial offset. Not sure why this is need, since the spectrum depends only on the span of the sampled data, not the origin. In any case, the waveform for z = 0.1 is around the zero crossing of the cosine, not near its peak.

 

3. When z =0, the sampled function is constant=1, giving only a bin(0) value = 1, the average (only thing present). When z is not zero, the cosine consists of two complex exponential components, each of amplitude 1/2, one at bin# = z and one at bin# = -z, which shows up at bin# = N-z since the spectrum is effectively periodic with N, the # of samples.moving from z=0 to z not 0 results in switching from one component with value 1 to two components of value 1/2 each. The FFT returns only one of these. You have to reconstruct the other.

 

The FFT assumes a real input, and returns only that part of the spectrum from 0 to fs/2. It does not return the upper half (fs/2 to fs) of the full spectrum, since these values are complex conjugates of the lower half. However, these missing values need to be included in any power calc.The CFFT function works with complex as well as real input waveforms, and returns the complete spectrum, with all components from 0 to fs. It works with any size vector. Unless dealing with a large # of transforms, I personally find the simplicity of using the CFFT worthwhile.

 

I think your worksheet is much too complicated to serve as a vehicle to explore DFT behavior. The best way to familiarize yourself with how the DFT functions behave is to work with a simple function - one real sinusoid, or even better, a single complex exponential. since the all the DFT's are linear. Learning how a single component works should help with more complicated behavior. Deal with sample #'s first and then set up with time and frequency. Keep track of how many cycles are in the complete sampling interval - this is the effective bin#. Note that if the input is sampled at k=0,1,2,...9, that the repeat sample span is 10, since this is assumed to be the same as k=0. the repeat interval is not 9.

 

Hope this helps,

Lou

3 replies

23-Emerald I
March 17, 2020

You need to read the Mathcad 15 help files on CFFT and FFT.

 

FFT and fft require a sample size that's a power of 2 long.  CFFT and cfft do not; any length is okay.  You did it right, 4096 samples.  But the amplitudes you're reporting are not correct.  Your first plot is I(0), if I break down the individual parts, then ploy the sum, we get:

Capture.JPG

and you report the fft as

Capture2.JPG

The first spike (the steady-state component) should be nearly 2, but reports as ~1, because of the way FFT scales its results (fft is different!) So fix that first.

 

I suspect that the reason the amplitude magnitudes switch around has to do with the phase relationship of the signals and the fact that you have a very short sample size.

 

21-Topaz II
March 17, 2020

Hi,

FFT must be supplied with a vector consisting of, for example, samples of a continuous function. The function must be sampled respecting the sampling theorem, that is, you need to know the sampling frequency. In your case the FFT argument is a function which in turn has only an independent variable z0 as its argument. In the function, however, the k that varies with q is also present. It does not seem to me that FFT receives an array of samples, but does what it can and returns what it can. An example of how you should proceed is the following:

square wave sampling 0.jpgsquare wave sampling 1.jpg

square wave sampling 2.jpgsquare wave sampling 3.jpg

Then, to know the amplitudes of the harmonics you can use the sliders as in the following figure relating to an IQ-QPSK signal:

square wave sampling 4.jpg

12-Amethyst
March 18, 2020

Can you save your file as an mcd11 version file and post that?

 

Thanks,

Lou

payman1-VisitorAuthor
1-Visitor
March 18, 2020

Yes, here you are.