Menu

How to calculate frequency of fft output, e.g. what is frequency at index 128?

simpletk
2022-01-06
2022-01-06
  • simpletk

    simpletk - 2022-01-06

    Here is simple FFT demo:

    * first line is ignored
    VU1 1 0 DC 0 AC 0.9 0 SIN(0 0.1 50 0 0 0)
    RR1 1 0 1000
    .control
    tran 100u 100m 0
    linearize v(1)
    set specwindow=blackman
    fft v(1)
    print vdb(1)
    .endc
    .end
    

    I run it from command line: "ngspice -b demo.src" and the output is:

    ... first 20 or so lines omitted
    Index vdb(1)
    0<->-2.93591e+02<-->
    1<->-9.77563e+01<-->
    2<->-1.06951e+02<-->
    3<->-4.24296e+01<-->
    4<->-2.56337e+01<-->
    .... some lines omitted
    124>-1.85311e+02<-->
    125>-1.88034e+02<-->
    126>-1.91794e+02<-->
    127>-1.98066e+02<-->
    128>-2.93557e+02<-->
    129>-1.98610e+02<-->
    .... some lines omitted
    124>-1.85311e+02<-->
    125>-1.88034e+02<-->
    126>-1.91794e+02<-->
    127>-1.98066e+02<-->
    128>-2.93557e+02<-->
    129>-1.98610e+02<-->

    So first column is index from 0 to 512 and second column is amplitude in db, how do I find out what frequency correspond for example to index 128 or index 50?

     
  • Holger Vogt

    Holger Vogt - 2022-01-06

    What about

    print frequency vdb(1)
    

    ?

     
  • simpletk

    simpletk - 2022-01-06

    It works, thanks

     

Log in to post a comment.