Multiple AC sweep simulation script

I would like to run a multiple ac sweep simulation on a simple LCR circuit plotting phase in degree and gain in db with different values of L, i’ve found a way but i dont’ know how to modify the script to print the gain in db

can someone help me?

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))