# 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.

## Creation

### Syntax

``meter = powermeter(len)``
``meter = powermeter(Name,Value)``

### Description

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

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.

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.

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

Tunable: Yes

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

• `'dBm'`

• `'dBW'`

• `'Watts'`

## Usage

### Syntax

``avgpwr = meter(x)``
``peakpwr = meter(x)``
``papr = meter(x)``
``[avgpwr,peakpwr,papr] = meter(x)``

### 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

 `step` Run System object algorithm `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset 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 $\mathrm{Vi}=\mathrm{Vmax}×\mathrm{sin}\left(2\pi \mathrm{ft}\right)$, where$Vi$ is the instantaneous value, $Vmax$ is the maximum voltage of the signal, and $\mathit{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 $\mathit{P}$ of the noisy sinusoidal signal is given by the following equation.

`$\mathit{P}=\frac{{\mathit{A}}_{1}^{2}}{2\mathit{R}}+\frac{{\mathit{A}}_{2}^{2}}{2\mathit{R}}+\mathrm{var}\left(\mathrm{noise}\right),$`

where,

• ${\mathit{A}}_{1}$ is the amplitude of the first sinusoidal signal.

• ${\mathit{A}}_{2}$ is the amplitude of the second sinusoidal signal.

• $\mathit{R}$ is the reference load in Ohms.

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

`${\mathrm{expPwr}}_{\mathrm{dBm}}=10{\mathrm{log}}_{10}\left(\mathit{P}\right)+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```

expand all

## Extended Capabilities

### Topics

Introduced in R2021a

Watch now