Does the rigol support advanced math functions?
If so maybe you could just use a user defined function
I looked at the user manual but it wasn't clear to me if you could combine the functions or just use them individually:
Math Operation
DS1000Z can realize various math operations (including: addition (A+B), subtraction (A-B), multiplication (AxB), division (A/B), FFT, A&&B, A||B, A^B, !A, Intg, Diff, Sqrt, Lg, Ln, Exp and Abs. The results of math operation also allows further measurement (for details, please refer to “Cursor Measurement”).
Press ? Math ? Operator in the vertical control area (VERTICAL) at the front panel to select the desired operator. The result of math operation will be displayed on the waveform marked with “M” on the screen after you press Display to enable the operation.