1
$\begingroup$

I have amplitude data varying with frequency for a signal. From that I want to generate time response in such a way so that if I take Fourier I can get the amplitude data back. I have written down the code to get time response based on this answer.

amplitude = ConstantArray[0, 1000];
amplitude[[{50}]] = {100};
fz = Table[i, {i, 1000, 10^6, 1000}];
amplitude2 = 
  Flatten[{amplitude, 
    Reverse[Conjugate[amplitude[[Range[2, Length[amplitude]]]]]]}];
OP = InverseFourier[amplitude2, FourierParameters -> {1, -1}];
timeresponse = Re[OP];

ListPlot[Transpose[{fz, amplitude}], Mesh -> All, 
 GridLines -> Automatic, PlotRange -> Full, Joined -> True, 
 TicksStyle -> Large]
ListPlot[timeresponse[[Range[2, Length[timeresponse]]]], 
 Joined -> True, PlotRange -> Full, TicksStyle -> Large]
ListPlot[Abs[Fourier[timeresponse, FourierParameters -> {1, -1}]][[
  1 ;; Length[amplitude]]], Joined -> True, PlotRange -> All, 
 TicksStyle -> Large]

Fz-Amp and time response

Actually I have very complex freq-amplitude data. In which various amplitude values are there for a large range of frequencies. How I can tell Mathematica that these values of amplitude are related with these harmonics of certain frequencies?

$\endgroup$
0
$\begingroup$

Actually here frequency information is not being fed to the InverseFourier. What fz you are giving that is just being used for information.

InverseFourier just have amplitude vector. Means value of amplitudes, with corresponding element number. If you scale whole output timeresponse on the time axis by frequency step^-1 (1000 in your case), than automatically you will get required time signal and then frequencies in that signal will be matching with your given amplitude-frequency data. Here is signal with 1 ms with 2000 data points.

And also multiply with the length of amplitude vector, that will give you right

OP = Length[amplitude]*InverseFourier[amplitude2, FourierParameters -> {1, -1}] Just see here. Time response

$\endgroup$

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.