# LTspice .meas

#### diyralf

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:

#### MarcelvdG

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:
1 user

#### diyralf

Works! Thanks. Seens to be a complex number horror.
res20: v(vout)=(-3.30797dB,-41.9239°) at 20
res1k: v(vout)=(-25.5767dB,-7.63957°) at 850
res2: res1k/res20=(-22.2688dB,34.2843°)