Main Content

powermeter

Measure power of voltage signal

Description

The powermeter System object™ computes the power measurements of a voltage signal. The power measurements include average power, peak power, and peak-to-average power ratio. The object uses the sliding window method to compute these measurements. For more details, see Algorithms.

To measure the power of a voltage signal:

  1. Create the powermeter object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

meter = powermeter(len) returns a power meter object with the WindowLength property set to len.

meter = powermeter(Len,Overlap) sets the WindowLength property to Len and the OverlapLength property to Overlap.

example

meter = powermeter(Name,Value) returns a power meter object with each specified property set to the specified value. Enclose each property name in quotes. You can use this syntax with the previous input argument.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Desired power measurement, specified as one of the following:

  • 'Average power' (default)

  • 'Peak power'

  • 'Peak-to-average power ratio'

  • 'All'

For details on how the object computes these measurements, see Algorithms.

Window length over which the measurement is computed, specified as a positive integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Overlap length between sliding windows, specified as a nonnegative integer. The value of overlap length varies in the range [0, WindowLength − 1]. If not specified, the overlap length is WindowLength − 1.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Reference load that the power meter uses to compute power values, specified as a real, positive scalar in ohms.

Tunable: Yes

Data Types: single | double

Units of the measured power values, specified as one of the following:

  • 'dBm'

  • 'dBW'

  • 'Watts'

Usage

Description

example

avgpwr = meter(x) computes the average power of the input signal x when the Measurement property is set to 'Average power'. Each column of x is an independent channel. The object computes the average power of each channel of the input signal independently.

peakpwr = meter(x) computes the peak power of the input signal x when the Measurement property is set to 'Peak power'. Each column of x is an independent channel. The object computes the peak power of each channel of the input signal independently.

papr = meter(x) computes the peak-to-average power ratio of the input signal x when the Measurement property is set to 'Peak-to-average power ratio'. Each column of x is an independent channel. The object computes the peak-to-average power ratio of each channel of the input signal independently.

example

[avgpwr,peakpwr,papr] = meter(x) computes the average power, peak power, and the peak-to-average power ratio of the input signal x when the Measurement property is set to 'All'. Each column of x is an independent channel. The object computes the power measurements of each channel of the input signal independently.

Input Arguments

expand all

Input voltage signal, specified as a vector or a matrix, and measured in volts. If x is a matrix, each column is treated as an independent channel. The power measurement is computed along each channel using the Sliding Window Method.

The object also accepts variable-size inputs. That is, once the object is locked, you can change the size of each input channel, but you cannot change the number of channels.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

expand all

Average power of the voltage signal, returned as a vector or a matrix, and measured in the units determined by the PowerUnits property. For details on how the object computes the average power, see Average Power.

Data Types: single | double

Peak power of the voltage signal, returned as a vector or a matrix, and measured in the units determined by the PowerUnits property. For details on how the object computes the peak power, see Peak Power.

Data Types: single | double

Peak-to-average power ratio of the voltage signal, returned as a vector or a matrix. For details on how the object computes the peak-to-average power ratio, see Peak-to-Average Power Ratio.

Data Types: single | double

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Compute the power measurements of a noisy sinusoidal signal using a power meter. These measurements include average power, peak power, and peak-to-average power ratio.

Assume the maximum voltage of the signal to be 100 V. The instantaneous values of a sinusoidal waveform are given by the equation Vi=Vmax×sin(2πft), whereVi is the instantaneous value, Vmax is the maximum voltage of the signal, and f is the frequency of the signal in Hz.

Initialization

The input signal is a sum of two sine waves with frequencies set to 1 kHz and 10 kHz, respectively. The frame length and the sampling frequency of the generated signal is 512 samples and 44.1 kHz, respectively.

To measure the power in this signal, create a powermeter object. Set 'Measurement' to 'All'. This setting enables the object to measure the average power, peak power, and peak-to-average power ratio. Set the length of the sliding window to 16 samples and the reference load to 50 Ohms. Use this object to measure the power in dBm units. Visualize the power measurements using the timescope object.

FrameLength = 512;
Fs = 44.1e3;
A = 100;
sine1 = dsp.SineWave('Amplitude',A,...
    'Frequency',1e3,...
    'SampleRate',44.1e3,...
    'SamplesPerFrame',FrameLength);
sine2 = dsp.SineWave('Amplitude',A,...
    'Frequency',10e3,...
    'SampleRate',44.1e3,...
    'SamplesPerFrame',FrameLength);
pm  = powermeter(16, 'Measurement', 'All', ...
                     'ReferenceLoad', 50, ...
                     'PowerUnits', 'dBm');
scope  = timescope('NumInputPorts',4,'SampleRate',Fs,...
                   'TimeSpanSource','property',...
                   'TimeSpan',96,...
                   'YLabel','dBm',...
                   'YLimits',[-30 90]);
title = 'Power Measurements';
scope.ChannelNames = {'Average power',...
    'Peak power','Peak-to-average power ratio',...
    'Expected Average Power'};
scope.Title = title;

Compute the Power Measurements

Add zero-mean white Gaussian noise with a standard deviation of 0.001 to the sum of sine waves. Vary the amplitude of the sine waves. Measure the average power, peak power, and the peak-to-average power ratio of this noisy sinusoidal signal that has a varying amplitude. For details on how the object measures these power values, see Algorithms. Compare the measured values to the expected value of the average power.

The expected value of the average power P of the noisy sinusoidal signal is given by the following equation.

P=A122R+A222R+var(noise),

where,

  • A1 is the amplitude of the first sinusoidal signal.

  • A2 is the amplitude of the second sinusoidal signal.

  • R is the reference load in Ohms.

In dBm, the expected power is computed using the following equation:

expPwrdBm=10log10(P)+30.

Compare the expected value with the value computed by the object. All values are in dBm. These values match very closely. To verify, view the computed measurements using the timescope object.

Vect = [1/8 1/2 1 2 1 1/2 1/8 1/16 1/32];
for index = 1:length(Vect)
    V = Vect(index);
    for i = 1:1000
        x = V*sine1()+V*sine2()+0.001.*randn(FrameLength,1);
        P = (((V*A)^2)/100)+(((V*A)^2)/100)+(0.001)^2;
        expPwr = (10*log10(P)+30)*ones(FrameLength,1);
        [avgPwr,pkPwr,papr] = pm(x);
        scope(avgPwr,pkPwr,papr,expPwr);
    end
end

Algorithms

expand all

Extended Capabilities

Introduced in R2021a