How do I draw the upper and lower envelope of a signal?

Add the filter function boundary(type, width) to a copy of the curve. UniPlot sorts the points by x, divides the x range into classes and follows the outermost points from class to class. With type = 2 you get the upper and the lower envelope in one curve.

Amplitude modulated vibration signal with its upper and lower envelope

Vibration signal (gray) with upper and lower envelope calculated with boundary(2, 2) (blue).

How it works

  1. Copy the curve (Ctrl+C, Ctrl+V), so the signal and its envelope are both visible.

  2. Right-click the copy, choose Edit Filter Functions…, select boundary and click =>.

  3. Click Edit and set the two parameters:

    • type: 0 upper envelope, 1 lower envelope, 2 both.

    • width: class width in percent of the x range, 1 to 100. Smaller values follow the signal more closely.

  4. Click OK.

In a script:

XYSetFilterFunctions(hData, "boundary(2, 2)");

Why it helps

  • Shows the amplitude of an oscillating signal at a glance, without drawing anything by hand.

  • Works for time signals and for point clouds, for example torque over speed.

  • The envelope is recalculated when the curve gets new data.

Good to know

  • Always give type explicitly; then the result does not depend on default values.

  • The class width controls the shape: with a large width the envelope only follows the slow trend, with a small width it follows single oscillations.

  • For the outline of a point cloud, for example the measured points of an engine map, convex_hull() gives a closed polygon around all points.

Measured engine map points with their convex hull

Measured map points and their outline calculated with convex_hull().