dsp.RMS System object

Package: dsp

Root mean square of vector elements

Description

The RMS object computes the root mean square (RMS) value.

To compute the RMS value of your input:

  1. Define and set up your RMS calculation. See Construction.

  2. Call step to compute the RMS value for an input according to the properties of dsp.RMS. The behavior of step is specific to each object in the toolbox.

Construction

H = dsp.RMS returns a System object™, H, that computes the root mean square (RMS) of an input or a sequence of inputs over the specified Dimension.

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

Properties

RunningRMS

Enable calculating RMS over time

Set this property to true to enable calculating the RMS over successive calls to the step method.

Default: false

ResetInputPort

Enable resetting in running RMS mode

Set this property to true to enable resetting the running RMS. When the property is set to true, you must specify a reset input to the step method to reset the running RMS. This property applies when you set the RunningRMS property to true.

Default: false

ResetCondition

Reset condition for running RMS mode

Specify the event to reset the running RMS as one of Rising edge, Falling edge, Either edge, or Non-zero. Non-zero resets the running RMS each time a nonzero sample is acquired. See Rising and Falling Edges for definitions of rising and falling edges. This property applies when you set the ResetInputPort property to true.

Default: Non-zero

Dimension

Dimension to compute RMS value along

Specify the dimension along which to calculate the RMS as one of All, Row, Column, or Custom. This property applies only when you set the RunningRMS property to false. Specifying the Dimension property as All computes 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 the Dimension property to Custom.

Default: 1

FrameBasedProcessing

Enable frame-based processing

Set this property to true to enable frame-based processing for 2-dimensional inputs. Set this property to false to enable sample-based processing. The object always performs sample-based processing for N-D inputs where N is greater than 2. This property applies when you set the RunningRMS property to true.

Default: true

Methods

cloneClones the current instance of the root mean square object
getNumInputsNumber of expected inputs to the step method
getNumOutputsNumber of outputs of the step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset the running root mean square object
stepRoot mean square of input

Definitions

Root-Mean-Square Level

The root-mean-square level of a vector, X, is

with the summation performed along the specified dimension.

Rising and Falling Edges

A rising edge:

  • Rises from a negative value to a positive value or zero.

  • Rises from zero to a positive value, where the rise is not a continuation of a rise from a negative value to zero.

A falling edge:

  • Falls from a positive value to a negative value or zero.

  • Falls from zero to a negative value, where the fall is not a continuation of a fall from a positive value to zero.

Examples

expand all

RMS Value of Vector Input

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

Create a row vector of the integers 1 to 10. Construct the RMS System object with the Dimension property set to 'literal'. Compute the RMS value.

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

RMS Value of Matrix Input

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

in2 = magic(4);
hrms2d = dsp.RMS;
hrms2d.Dimension = 'All';
y_rms2 = step(hrms2d, in2);

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.

Algorithms

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

  • Treat sample-based row input as a column block parameter is not supported by the dsp.RMS object.

  • Reset Port block parameter corresponds to both the ResetCondition and the ResetInputPort object properties.

Both this object and its corresponding block let you specify whether to process inputs as individual samples or as frames of data. The object uses the FrameBasedProcessing property. The block uses the Input processing parameter. See Set the FrameBasedProcessing Property of a System object for more information.

Was this topic helpful?