Power Spectrum of a function
Author's Data: Housam Binous
Department of Chemical Engineering
National Institute of Applied Sciences and Technology
Tunis, TUNISIA
Email: binoushousam@yahoo.com

Acknowledgement :

This example of the was given by Kenneth J. Beers in Numerical Methods for Chemical Engineering, Applications in Matlab, Cambridge University Press, 2007.

Ni = 2^8;

P = 10.  Pi;

dt = 2 P/Ni

t = Table[i, {i, 0, 2 P - dt, dt}];

f[t_] := Sin[t] + 2 Cos[2 t]

Plot of the function f(t) = sin(t) + 2 cos(t).

plt1 = 
      Plot[f[t], {t, 0, 20}, 
        PlotStyle ->  RGBColor[1, 0, 0]]

pp=2 Abs[Fourier[f[t],FourierParameters -> {-1, 1}]]//Chop;

omgmax = Pi/dt

domg = Pi/P

omg = Table[i, {i, 0, 2 omgmax - domg, domg}];

Length[pp]

Length[omg]

The power plot of f(t) is obtained below. Two peaks are found at w=1 and w=2 as well as their relative intensity 1:2.

ListPlot[Table[{omg[[i]], pp[[i]]}, {i, 1, Length[omg]/2}], 
      PlotJoined ->  True, 
      PlotStyle ->  RGBColor[1, 0, 0]]