主要内容

rms

Root mean square value of signal data

Since R2026a

    Description

    sigRms = rms(sigObj) returns the root mean square value of the data values in the Simulink.sdi.Signal object sigObj.

    example

    sigRms = rms(sigObj,startTime) returns the root mean square value in the time interval between startTime and the end of simulation.

    sigRms = rms(sigObj,startTime,endTime) returns the root mean square value in the time interval specified by startTime and endTime, inclusive.

    Examples

    collapse all

    Suppose you log a signal generated from a Random Number block to the Simulation Data Inspector. You can get descriptive statics about the logged signal using the Simulink.sdi.Signal object.

    A signal generated from a Random Number block plotted on a time plot in the Simulation Data Inspector.

    Access the Simulink.sdi.Signal object for the signal named mySig.

    runObj = Simulink.sdi.Run.getLatest;
    sigObj = getSignalsByName(runObj,"mySig");

    Find the root mean square value for the signal using the rms function.

    rmsVal = rms(sigObj)
    rmsVal =
    
        0.9470

    To find the root mean square value of the signal near the end of the simulation, specify the starting time. For example, to find the root mean square value in the last two seconds of the simulation, specify startTime as 8.

    rmsValEnd = rms(sigObj,8)
    rmsValEnd =
    
        0.9600

    To find the root mean square value of the signal in a specific interval, specify the start and end time to search in. For example, find the root mean square value between 2 seconds and 4 seconds.

    rmsValInterval = rms(sigObj,2,4)
    rmsValInterval =
    
        0.8825

    Input Arguments

    collapse all

    Input signal, specified as a numerical scalar Simulink.sdi.Signal object.

    To find the root mean square value of a composite signal element, such as a bus element, or the root mean square value of the real or imaginary part of a complex signal, use the Children property. The Children property contains Simulink.sdi.Signal objects that make up the composite signal or real and imaginary parts of the complex signal.

    • For composite signals, access elements in the Children property by index.

    • For complex signals, the first element in the Children property is the real part of the complex signal and the second element is the imaginary part.

    Example: rmsVal = rms(complexSig.Children(1))

    Start time, specified as a nonnegative scalar less than endTime. This time specifies the beginning of the time interval in which to find the root mean square value.

    End time, specified as a nonnegative scalar greater than startTime and less than the simulation time. This time specifies the end of the time interval in which to find the root mean square value.

    Output Arguments

    collapse all

    Root mean square value, returned as a scalar.

    Version History

    Introduced in R2026a