# movavg (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info Download Help (Windows Only)

Owning Class: statistics

Requires: MathScript RT Module

## 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’)

## Description

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.

Examples

## Inputs

Name Description
x Specifies the 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 Specifies the averaging length for long-term moving average. b is a positive integer, and b is larger than or equal to a.
alpha Specifies the weighting power of the delay. alpha is a real, double-precision, floating-point scalar. The default is 0.
'e' Specifies to calculate the exponential moving average.

## Outputs

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

## Details

The following table lists the support characteristics of this function.

 Supported in the LabVIEW Run-Time Engine Yes (if you request output) Supported on RT targets Yes (if you request output) Suitable for bounded execution times on RT Not characterized

## Examples

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