LTspice .meas

Does anyone know how to calculate the difference of two dB-levels? Something wrong comes out of this.

.meas AC res20 FIND MAG(V(Vout)) AT 20
.meas AC res1k FIND MAG(V(Vout)) AT 850
.meas res2 PARAM MAG(res1k)-MAG(res20)

strg-L: ->

res20: mag(v(vout))=(-3.30797dB,0°) at 20
res1k: mag(v(vout))=(-25.5767dB,0°) at 850
res2: mag(res1k)-mag(res20)=(-4.00405dB,180°) <---- -22dB expected
 
Last edited:
You probably get the answer you want when you divide rather than subtract them.

It seems to me that MAG(x) is interpreted as the magnitude of x. That is, the scale is linear rather than dB.

After the subtraction is done, for some reason I don't understand, the result is converted to decibels and degrees. A magnitude is by definition 0 or positive real, in the latter case its phase is by definition 0 degrees.

As res20 has a greater magnitude than res1k, the result of the subtraction is negative, so its phase is 180 degrees.
 
Last edited:
  • Like
Reactions: 1 user