Multiple AC sweep simulation script

For an AC Sweep, an Impulse Response Analysis or a Multitone Analysis, the command returns a struct consisting of three fields, F, Gr and Gi. F is a vector that contains the perturbation frequencies of the analysis. The rows of the arrays Gr and Gi consist of the real and imaginary part of the transfer function as defined in the analysis.

To get the gain in dB, one can just convert the magnitude of the Gr+1j*Gi and convert.

R = plecs('analyze', 'AC Sweep');

R.Gc = R.Gr+1j*R.Gi;

dBGain = 20*log(abs(R.Gc))