主要内容

RMS

R2026b

Compute root mean square or mean square value of time-domain signal

Since R2026b

Libraries:
Power Converter Control with Motor Control Blockset / Measurement

Description

The RMS block computes the root mean square (RMS) or mean square value of a time-domain input signal over a sliding or fixed measurement window. Use this block to measure the effective magnitude of periodic or quasi-periodic signals such as AC voltages and currents. You can configure the window size, measurement mode, and whether the block outputs the RMS or mean square value.

Ports

Input

expand all

Input signal to measure, specified as a scalar. The block computes the RMS or mean square value of this signal over the measurement window.

Data Types: single | double

Reset trigger signal, specified as a scalar. A rising edge on this port resets the measurement window.

Dependencies

To enable this port, set Measurement mode to Moving window (default).

Data Types: single | double | Boolean

Input frequency signal, specified as a positive scalar in Hz. The block uses this frequency to determine the measurement window length.

Dependencies

To enable this port, set Input frequency type to Input port.

Data Types: single | double

Measurement restart trigger signal, specified as a scalar. A rising edge on this port restarts the fixed-window measurement cycle.

Dependencies

To enable this port, set Measurement mode to Fixed window.

Data Types: single | double | Boolean

Output

expand all

Root mean squared value of the input signal, returned as a scalar.

Dependencies

To enable this port, set Block output to Root mean square (default).

Data Types: single | double

Mean square value of the input signal, returned as a scalar.

Dependencies

To enable this port, set Block output to Mean square.

Data Types: single | double

Measurement window completion status, returned as a scalar. The signal indicates whether the fixed-window measurement cycle is complete.

Dependencies

To enable this port, set Measurement mode to Fixed window.

Data Types: single | double | Boolean

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Type of measurement output. Select Root mean square to output the RMS value of the input signal. Select Mean square to output the mean square value.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: BlkOutput
Values: "Root mean square" (default) | "Mean square"

Example: set_param(gcb,"BlkOutput","Mean square")

Simulation discrete sample time, specified in seconds. This value determines how often the block executes and updates the measurement output. Set this to match the fixed-step solver step size of your model. A smaller value increases measurement resolution but adds computational cost.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: BlkSampleTime
Values: "50e-6" (default) | positive scalar in quotes
Data Types: char | string

Example: set_param(gcb,"BlkSampleTime","100e-6")

Source for the measurement frequency. Select Specify via dialog to use the Initial frequency value (Hz) parameter. Select Input port to supply the frequency from an input port.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: InputFrequencyType
Values: "Specify via dialog" (default) | "Input port"

Example: set_param(gcb,"InputFrequencyType","Input port")

Fundamental frequency of the input signal, specified in Hz. The block uses this frequency to determine the measurement window length. For a 50 Hz grid, set this to 50; for a 60 Hz grid, set this to 60. The measurement window spans one complete cycle at this frequency.

Dependencies

This parameter is visible when Input frequency type is set to Specify via dialog.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: InputFrequency
Values: "50" (default) | positive scalar in quotes
Data Types: char | string

Example: set_param(gcb,"InputFrequency","60")

Windowing method for RMS computation. Select Moving window to continuously update the measurement over a sliding window. Select Fixed window to compute the measurement over a fixed number of cycles and hold the result until restarted.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: MeasurementMode
Values: "Moving window" (default) | "Fixed window"

Example: set_param(gcb,"MeasurementMode","Fixed window")

Lower bound for the input frequency range, specified in Hz. The block uses this value to allocate the internal buffer that stores samples for one measurement window. A lower frequency requires more buffer memory because the measurement window spans more samples. Set this to the lowest frequency your application needs to measure accurately.

Dependencies

This parameter is visible when Input frequency type is set to Input port.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: MinimumFrequency
Values: "1000" (default) | positive scalar in quotes
Data Types: char | string

Example: set_param(gcb,"MinimumFrequency","500")

Number of signal cycles in the fixed measurement window. The block computes the measurement over this many complete cycles before holding the output. Increasing this value improves measurement accuracy by averaging over more cycles, but increases the time before the first valid output is available.

Dependencies

This parameter is visible when Measurement mode is set to Fixed window.

Programmatic Use

To set the block parameter value programmatically, use the set_param function.

Parameter: NumCycle
Values: "1" (default) | positive integer in quotes
Data Types: char | string

Example: set_param(gcb,"NumCycle","2")

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2026b