Documentation

dsp.RMS System object

Root mean square of vector elements

Description

TheRMSobject computes the root mean square (RMS) value.

To compute the RMS value of your input:

  1. Define and set up your RMS calculation. SeeConstruction.

  2. Callstepto compute the RMS value for an input according to the properties ofdsp.RMS. The behavior ofstepis specific to each object in the toolbox.

Note

Starting in R2016b, instead of using thestepmethod to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example,y = step(obj,x)andy = obj(x)perform equivalent operations.

Note

TheRunningmode in thedsp.RMSSystem object will be removed in a future release. To compute the running RMS in MATLAB®, use thedsp.MovingRMSSystem object instead.

Construction

rms = dsp.RMSreturns a System object,rms, that computes the root mean square (RMS) of an input or a sequence of inputs over the specifiedDimension.

rms = dsp.RMS('PropertyName',PropertyValue,...)returns anRMSSystem object,rms, with each specified property set to the specified value.

Properties

RunningRMS

Enable calculating RMS over time

Set this property totrueto enable calculating the RMS over successive calls to thestepmethod.

Default:false

ResetInputPort

Enable resetting in running RMS mode

Set this property totrueto enable resetting the running RMS. When the property is set totrue, you must specify a reset input to thestepmethod to reset the running RMS. This property applies when you set theRunningRMSproperty totrue.

Default:false

ResetCondition

Reset condition for running RMS mode

Specify the event to reset the running RMS as one ofRising edge,Falling edge,Either edge, orNon-zero.Non-zeroresets the running RMS each time a nonzero sample is acquired. SeeRising and Falling Edgesfor definitions of rising and falling edges. This property applies when you set theResetInputPortproperty totrue.

Default:Non-zero

Dimension

Dimension to compute RMS value along

Specify the dimension along which to calculate the RMS as one ofAll,Row,Column, orCustom. This property applies only when you set theRunningRMSproperty tofalse. Specifying theDimensionproperty asAllcomputes the RMS value over the entire input.

Default:Column

CustomDimension

Numerical dimension to operate along

Specify the dimension (one-based scalar integer value) of the input signal, along which the RMS is computed. The cannot exceed the number of dimensions in the input signal. This property applies when you set theDimensionproperty toCustom.

Default:1

Methods

reset Reset the running root mean square object
step Root mean square of input
Common to All System Objects
release

Allow System object property value changes

Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstepsyntax. For example, myObject(x) becomes step(myObject,x).

Compute the RMS value of a vector consisting of the integers 1 to 10.

x = 1:10; rms = dsp.RMS('Dimension','row'); rmsval = rms(x)
rmsval = 6.2048

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalentstepsyntax. For example, myObject(x) becomes step(myObject,x).

Compute the RMS value of a matrix with theDimensionproperty set to'All'.

in2 = magic(4); rms2d = dsp.RMS; rms2d.Dimension ='All'; y_rms2 = rms2d(in2)
y_rms2 = 9.6695

The output is equivalent to reshaping the 4-by-4 matrix into a 16-by-1, or 1-by-16 vector and computing the RMS value for the vector.

More About

expand all

Algorithms

This object implements the algorithm, inputs, and outputs described on theRMSblock reference page. The object properties correspond to the Simulink®block parameters, except:

  • Treat sample-based row input as a columnblock parameter is not supported by thedsp.RMSobject.

  • Reset Portblock parameter corresponds to both theResetConditionand theResetInputPortobject properties.

Extended Capabilities

Introduced in R2012a

Was this topic helpful?