# movavg

Version:

Calculates the short-term and long-term moving average of an input signal. If you do not specify an output, this function plots the input signal, the long-term moving average, and the short-term moving average in the current plot window.

## Syntax

movavg(x, a, b)
movavg(x, a, b, alpha)
movavg(x, a, b, 'e')
short = movavg(x, a, b)
short = movavg(x, a, b, alpha)
short = movavg(x, a, b, 'e')
[short, long] = movavg(x, a, b)
[short, long] = movavg(x, a, b, alpha)
[short, long] = movavg(x, a, b, 'e')

## x

Input signal. x is a real, double-precision, floating-point scalar or vector.

## a

Specifies the averaging length for short-term moving average. a is a positive integer.

## b

Averaging length for long-term moving average. b is a positive integer, and b is larger than or equal to a.

## alpha

Weighting power of the delay. alpha is a real, double-precision, floating-point scalar.

Default: 0

## 'e'

Specifies to calculate the exponential moving average.

## short

Short-term moving average of the input signal. short is a real, double-precision, floating-point scalar or vector.

## long

Long-term moving average of the input signal. long is a real, double-precision, floating-point scalar or vector.

X = [1  2 3 4 5];
[short, long] = movavg(X, 2, 4)

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices