1
$\begingroup$

I have this question:

Create a time series of the function $\sin(7*\sin(140*t))$ with a sampling rate of $1000Hz$ for a time duration of $2.5s$. Fourier transform this time series and identify the absolute value (amplitude) of the largest Fourier component in the range $0$ Hz to $450$ Hz.

My code so far is:

ClearAll["Global`*"]
numpt = 2500; dt = 400; T = dt numpt;
data = Table[Sin[7*Sin[140*t]], {t, 0, T - dt, dt}];
fdata = Abs[Fourier[data]];
MaxValue[fdata]]

However i am struggling to find the max value in the range.

$\endgroup$

1 Answer 1

4
$\begingroup$
ClearAll["Global`*"]
sampleRate = 1000.; duration = 2.5; dt = 1/sampleRate;
data = Table[Sin[7*Sin[140*t]], {t, 0, duration, dt}];
fdata = Abs[Fourier[data]];
todecibels[pwr_] := 10 Log10[pwr]
peaks = {#[[1]]/duration, todecibels[#[[2]]^2]} & /@ FindPeaks[fdata];
Periodogram[data, SampleRate -> sampleRate, 
 PlotRange -> {{0, 600}, Full}, ScalingFunctions -> "dB", 
 Epilog -> {Red, Point[peaks]}]

peaks

hz peaks

Your peaks are at these frequencies (in Hz), and amplitudes in dB:

{{0.4, -29.9564}, {22.8, -12.4852}, {67.2, 17.9721}, {112., 22.7784},
 {156.4, 21.26}, {201.2, 6.14708}, {245.6, -7.45039}, {290.4, -31.4171},
 {334.8, -43.1615}, {666.4, -43.1615}, {710.8, -31.4171}, {755.6, -7.45039}, 
 {800., 6.14708}, {844.8, 21.26}, {889.2, 22.7784}, {934., 17.9721},
 {978.4, -12.4852}, {1000.4, -29.9564}}
$\endgroup$
3
  • $\begingroup$ Ignore the frequencies above 500 Hz. The Fourier transform is symmetrical. $\endgroup$
    – flinty
    Oct 27, 2020 at 16:38
  • $\begingroup$ I was wondering if there a code to stop displaying the max peak after 450Hz. $\endgroup$ Oct 27, 2020 at 18:14
  • 1
    $\begingroup$ @PhysicsQuestion yes, Select[peaks, First[#]<450&] $\endgroup$
    – flinty
    Oct 27, 2020 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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