From: Rune Allnor on
On 8 Jul, 20:46, Parlous <parlous2...(a)gmail.com> wrote:

> Given only the frequency (F) and FFT data (f), how would one determine
> both the phase (p) and amplitude (a)?

One doesn't.

Magnitude [*] and phase are only used in designs of filters.
For signal analysis purposes they are almost never used.
I can't think of a single analysis application where these
parameters are even estimated. You have already discovered
one argument why they are awkward to work with; the other is
that the statistical analysis of sinusoidal estimators show
that these parameters are very sensitive to noise and other
errors.

I have a vague recollection that somebody once upon a time
came up with one such application, so I'll challenge you to
come up with two applications where these parameters are
relevant.

Rune

[*] Amplitude is a signed real number while magnitude is a positive
real number, that is only relevant alongside phase as a polar
representation of a coplex number.
From: Dave on
On Jul 8, 2:46 pm, Parlous <parlous2...(a)gmail.com> wrote:
> Suppose one generates a sine or cosine wave in discrete domain.
> Suppose we are using floating-point numbers for the amplitude values
> between -1 and 1. Suppose we generate 2048 consecutive samples at
> 44100Hz sampling rate. Now compute a FFT on those 2048 samples with
> rectangular window (ie - do nothing else to the samples but put them
> in DFT). Here is some MATLAB code:
>
> x = 0:2047;    % time-domain
> F = 82.407;    % hertz
> p = pi/4;        % phase
> y = sin(2*pi*F .* x/44100 + p);
> f = fft(y);
>
> Now in this example, the amplitude is 1. Since the chosen frequency
> (82.407) is not one of the exact frequency bins, how does one
> ascertain what p is if one knows the frequency and has the FFT data
> only? Utilizing atan(imag(f1) ./ real(f1)) doesn't seem to help
> much...
>
> Now assume y is as follows:
>
> a = rand(1,1);
> y = a * sin(2*pi*F .* x/44100 + p);
> f = fft(y);
>
> Given only the frequency (F) and FFT data (f), how would one determine
> both the phase (p) and amplitude (a)?
>
> Thanks

Given a particular type of window (Rectangular, Hamming etc) the
leakage is deterministic in a noise free case. So you can create a
table of leakage values. So assume your FFT bins are 0,1,2, ...
Then you generate frequencies at the following frequencies 0, 0.1,
0.2 ,0.3, ... 1.0.

Then given your dataset you use the peak bin and the next largest FFT
bin next to it, and use the look up values. You can interpolate to get
better values.

Doing this you can get better estimates of the Amplitude and
Frequency. I haven't done it for phase, but it should work as well.

Note there are several assumptions:
1 - fairly high SNR - noise corrupts the process.
2 - Pure sinusoid as input
3 - Other nearby sinusoids in freq. will also corrupt the estimate,
since each one has its own leakage

From my own experience the rectangular windows has the worst
performance with this technique. Most other windows (Kaiser, Hamming,
Hanning) produce very similar results.

Cheers,
David
From: Clay on
On Jul 9, 12:40 am, Parlous <parlous2...(a)gmail.com> wrote:
> This posses another unusual problem - how does one choose the
> appropriate increment for the amplitude and phase? One can think of
> each like a "counter", just like digits in a counting system.
> Theoretically, considering these particular "counters" are derived
> from a continuous domain, one has to wonder how can to seemingly
> infinitely dense segments [0, 1] and [-pi, pi] could be counters? Its
> like infinity times infinity number of combinations!! Well, the
> computer is obviously limited but I don't think that I need to even go
> that far, to push the limits of floating-point numbers. From my MATLAB
> experiments an amplitude increment of 0.0001 and phase increment of
> 2*pi/100 are just fine. Its an interesting theoretical question though
> - would the real and imaginary values considered as one "value" or
> "key" together be unique for the possible amplitude and phase
> combinations, if one made an "ordered set" of such combinations?
> Again, this is all assume ONE generated, known frequency into the FFT.

Hello Parlous,

If we assume you have only one frequency and the SNR is good, we can
apply a linear algebra approach and extract the correct Fourier Coef
from the Fourier Coef of the nearest loudest bin. I have worked out an
example and put it into the following .pdf file. This was written in
MathCad, but I think you can see what I did. Sorry I don't do MatLab.

http://www.claysturner.com/phaseshiftamplitude.pdf

But as you can see this works from a single FFT bin's data! The peril
is sensitivity to noise. There are ways to deasl with that, but get
this working 1st.

Clay


From: Parlous on

Wow, thanks Clay! I haven't tried the solution yet, I've had to travel
about this weekend to playing music later. The computed constants
a,b,c and d are new to me, they remind me of solutions of the wave
equation with initial-conditions. This will solve my problem, thank
you very much...
From: Ron N. on
On Jul 8, 12:06 pm, Clay <c...(a)claysturner.com> wrote:
> I'm glad you understand the "leakage" problem as that really screws up
> the phase estimate when your frequency is not exactly in a bin.

Only because of a poor choice of reference phase. If you
reference your FFT phase to the center of the FFT aperture
(either by a pre-fftshift of the data, or by flipping the
phase of alternate bins of the FFT result), the evenness to
oddness ratio of any sinusoid with reference to the center of
the aperture, and thus its phase, can be easily interpolated
at the frequency sweeps between bins.

And if you have an estimate of the frequency and its phase
with reference to the center of a frame, you can easily
re-reference that phase (back) to any other point in the
frame, if so needed.


IMHO. YMMV.
--
rhn A.T nicholson d.0.t C-o-M
http://www.nicholson.com/rhn/dsp.html