0
$\begingroup$

Consider that we have a discrete signal of finite length. How can we find the amplitude and phase corresponding to different harmonics of this signal in Matlab?

Thanks.

$\endgroup$
  • 1
    $\begingroup$ so the discrete-time signal is periodic? $\endgroup$ – robert bristow-johnson Jul 6 '17 at 15:24
  • $\begingroup$ yes, that's periodic. $\endgroup$ – math14 Jul 6 '17 at 15:27
  • $\begingroup$ do you know the period in advance? is it an integer number of samples? $\endgroup$ – robert bristow-johnson Jul 6 '17 at 15:53
  • 1
    $\begingroup$ how about using Matlab's FFT? I mean that's pretty much the definition of a Fourier Transorm, if your signal is deterministic. You just have to apply Matlab's fft function (maybe zero-padding your signal if the length is very short) and then obtain the phase with angle() and the magnitude with abs() $\endgroup$ – Florent Jul 7 '17 at 4:32
  • $\begingroup$ @FlorentEcochard: can you describe the relationship between the coefficients of the DFT of finite length discrete signal with the harmonics of that (because of that the signal is finite length and I'd like to know clearly the difference of harmonics of Fourier series of a periodic signal and the DFT of a finite length signal)? $\endgroup$ – math14 Jul 8 '17 at 3:08
0
$\begingroup$

As Florent told: you must take fourier transform from your signal, by fft, then you will get your spectrum in normalized frequency, actual frequency is correspond to your sampling rate, then you can see amplitude and phase of each frequency(or harmonic) by these command: abs and angle. For example, assume x is signal and T is time interval between your samples and

x=[10 -10 10 -10 10 -10 -10 10 10 -10 -10]
X=fft(x);%you can set frequency resolution by setting fft(x,resolution)
Fs=1000;
f=linspace(1,Fs,length(X));
plot(f,angle(X))
figure
plot(f,abs(X))
$\endgroup$
0
$\begingroup$

The Fourier transform of a periodic signal is the discretisation of the Fourier transform of one of the signal's period. In other words, the only difference between the Fourier transform of a finite signal and its periodic version is that the former is continuous whereas the latter is discrete (Fourier series). To speak in mathematical terms, periodisation of a signal is equivalent to convolution with a Dirac train, which in the frequency domain results in the multiplication by a Dirac train, i.e. discretisation. Here is an explicative link

However, if your signal is not finite length but you're just analysing one finite portion of it (which is called windowing of the signal), this is equivalent to multiplying your time signal by a window function. In the frequency domain, it is like convolution with a sinc function (granted that your window is a rectangle window). More about this here.

So the bottom line is: if your fft window is big enough to analyse your whole signal, then the fft coefficients are a direct image of your harmonics. If you fft window truncates the signal however, you loose information and there is no way of knowing the original signal's real harmonics.

Note : I'm on my phone now so I can't illustrate with math equations but I'll edit later

$\endgroup$
  • $\begingroup$ There's a lot more to it : different apodizations of the window to prevent discontinuities, zero padding of your signal to have more FFT points, choice of a fft length that is a power of 2 to take advantage of the fft algorithm etc. Plenty of info on the web $\endgroup$ – Florent Jul 8 '17 at 3:40
  • $\begingroup$ "To speak in mathematical terms, periodisation of a signal is equivalent to convolution with a Dirac train, which in the frequency domain results in the multiplication by a Dirac train, i.e. discretisation." --- i think a more concise way to put it is: "Uniform sampling in one domain is equivalent to periodic extension in the reciprocal domain and, due to duality of the Fourier transform, periodical extension in one domain is equivalent to uniform sampling in the reciprocal domain." $\endgroup$ – robert bristow-johnson Jul 8 '17 at 4:18
  • $\begingroup$ Thanks @FlorentEcochard. Could you extend your answer specifically the second paragraph? About harmonics? $\endgroup$ – math14 Jul 8 '17 at 7:47
  • $\begingroup$ @robert bristow-johnson : right, much clearer thanks! Should I edit? $\endgroup$ – Florent Jul 8 '17 at 16:44
  • $\begingroup$ @Steve : what do you want to know? Please be more specific $\endgroup$ – Florent Jul 8 '17 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.