selectResult('tran)
time_vec = drGetWaveformXVec( v("/Vout") )
tstop = drGetElem( time_vec, drVectorLength(time_vec)-1 )
printf("tstop = %g[usec]\n", tstop/1u)
fmax = 25M
tw_in = 1.0/(5*fmax)
froll_off = 1.0 / tw_in
fnyquist = 2*froll_off
delta_f = 1.0 / tstop
maxstep = 1.0 / fnyquist
N = round(2*fnyquist * tstop)
ip = round(log(N)/log(2))
NN = 2**ip
if( NN < N then NN=2**(ip+1) )
fnyquist = NN / (2.0*tstop)
printf("N = %d --> N = %d\n", N NN)
k = tstop / (2.0 * tw_in) ; Amplitude Compensation
Vout_freq = dft(v("/Vout") 0 tstop N "Rectangular" 1 1)
Vref_freq = dft(v("/Vref") 0 tstop N "Rectangular" 1 1)
xvec = drGetWaveformXVec(Vout_freq)
len = drVectorLength(xvec)
printf("len = %d\n", len)
bid = currentSubwindow(1)
plot( db20(k*Vout_freq) ?expr '("tran-S21 without roll-off compensation") )
plot( db20(Vout_freq/Vref_freq) ?expr '("tran-S21 with roll-off compensation") )