I have a dataset following cosine function [e.g. cos(200t)] in time domain. In frequency domain two sharp lines should appear at -200 and +200. I have to do Fourier transform (or Fast Fourier transform) for that. I have tried the following code:
TDsignal = Table[{t, Cos[200 t]}, {t, 0, 1, 0.001}];
freq = Table[i/(Length[TDsignal[[All, 2]]] 0.001 ), {i, -((
Length[TDsignal[[All, 2]]] - 1)/2), (
Length[TDsignal[[All, 2]]] - 1)/2}];
FDdata = Transpose[{freq, Fourier[TDsignal[[All, 2]], FourierParameters -> {1, -1}]}];
Grid[{{ListLinePlot[TDsignal, PlotRange -> All, Axes -> False,
Frame -> True, FrameLabel -> {Style["time (s)", 12, FontFamily -> "Arial",
Bold], Style["TD signal (au)", 12, FontFamily -> "Arial",
Bold]}, PlotStyle -> Hue[0.01, 0.43, 1.], AspectRatio -> 0.714,
ImageSize -> 450],
ListLinePlot[Re@FDdata, PlotRange -> All, Axes -> False,
Frame -> True, FrameLabel -> {Style["Frequncy (Hz)", 12, FontFamily -> "Arial",
Bold], Style["FFT Signal (au)", 12, FontFamily -> "Arial",
Bold]}, PlotStyle -> Hue[0.5, 0.43, 1.], AspectRatio -> 0.714,
ImageSize -> 450]}}]
It returns some lines but not at +/-200 (the plot what I got is attached here)
, but mathematically it must be at +/- 200.
What is the mistake I am doing?
Any lead will be really helpful.
cos[2*pi*200*t];has frequency of 200 HZ? The x-axis is in HZ, not radians per second or any other units. – Nasser Nov 10 '23 at 21:30Cos[2*Pi*200*t]as the signal. This is not exactly what you had. I did this to make it more clear. You hadCos[200 t], so you just need to transform yours to same form if you want to use my code. – Nasser Nov 10 '23 at 21:35