Hello Cristan,
You have two chances for your measurements.
1. Export the waveform data and analyze it with an external Math-program.
File -> Export
2. Calculate with .measure.
Below is an example for a THD calculation. The many SPICE-directives can reside in an extra file.
Please take a look this example.
Files > Tut > Measure > Tran > jfet_amp_disto_plot.zip
You can apply the same method for IM, but then you will need a long simulation time proportional to 1/(f2-f1) for useful results
Best regards,
Helmut
.measure Arms rms V(out)
.measure Aavg avg V(out)
?
.measure A2re avg? (V(out)-Aavg)*cos(360*time*Freq*2)
.measure A2im avg (V(out)-Aavg)*sin(360*time*Freq*2)
.measure K2 param 100*hypot(A2re,A2im)/Arms*sqrt(2)
?
.measure A3re avg? (V(out)-Aavg)*cos(360*time*Freq*3)
.measure A3im avg (V(out)-Aavg)*sin(360*time*Freq*3)
.measure K3 param 100*hypot(A3re,A3im)/Arms*sqrt(2)
?
.measure A4re avg? (V(out)-Aavg)*cos(360*time*Freq*4)
.measure A4im avg (V(out)-Aavg)*sin(360*time*Freq*4)
.measure K4 param 100*hypot(A4re,A4im)/Arms*sqrt(2)
?
.measure A5re avg? (V(out)-Aavg)*cos(360*time*Freq*5)
.measure A5im avg (V(out)-Aavg)*sin(360*time*Freq*5)
.measure K5 param 100*hypot(A5re,A5im)/Arms*sqrt(2)
?
.measure A6re avg? (V(out)-Aavg)*cos(360*time*Freq*6)
.measure A6im avg (V(out)-Aavg)*sin(360*time*Freq*6)
.measure K6 param 100*hypot(A6re,A6im)/Arms*sqrt(2)
?
.measure A7re avg? (V(out)-Aavg)*cos(360*time*Freq*7)
.measure A7im avg (V(out)-Aavg)*sin(360*time*Freq*7)
.measure K7 param 100*hypot(A7re,A7im)/Arms*sqrt(2)
?
.measure A8re avg? (V(out)-Aavg)*cos(360*time*Freq*8)
.measure A8im avg (V(out)-Aavg)*sin(360*time*Freq*8)
.measure K8 param 100*hypot(A8re,A8im)/Arms*sqrt(2)
?
.measure A9re avg? (V(out)-Aavg)*cos(360*time*Freq*9)
.measure A9im avg (V(out)-Aavg)*sin(360*time*Freq*9)
.measure K9 param 100*hypot(A9re,A9im)/Arms*sqrt(2)
.measure thd param sqrt(K2*K2+K3*K3+K4*K4+K5*K5+K6*K6+K7*K7+K8*K8+K9*K9)