# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# dsp.PhaseExtractor System object

Extract the unwrapped phase of a complex input

## Description

The `PhaseExtractor` object extracts the unwrapped phase of a complex input.

To extract the unwrapped phase of a signal input:

1. Define and set up your `dsp.PhaseExtractor` System object™. See Construction.

2. Call `step` with your input signal to extract the signal phase according to the properties of this System object. The behavior of `step` is specific to each object in the toolbox.

### Note

Starting in R2016b, instead of using the `step` method to perform the operation defined by the System object, you can call the object with arguments, as if it were a function. For example, ```y = step(obj,x)``` and `y = obj(x)` perform equivalent operations.

## Construction

`phase = dsp.PhaseExtractor` returns a System object, `phase`, that extracts the unwrapped phase of an input signal.

`phase = dsp.PhaseExtractor('PropertyName',PropertyValue,...)` returns a System object, `phase`, with each specified property set to the specified value.

## Properties

 `TreatFramesIndependently` Specify if you want to reset the unwrapped phase at the end of a frame. If you set this property to: `true`: The object treats each frame of data independently. It resets the initial cumulative unwrapped phase to zero each time a new input frame is received.`false`: The object ignores boundaries between frames when returning the unwrapped phase. The default value is `false`.

## Methods

 reset Reset internal states of object step Extract phase of signal input
Common to All System Objects
`clone`

Create System object with same property values

`getNumInputs`

Expected number of inputs to a System object

`getNumOutputs`

Expected number of outputs of a System object

`isLocked`

Check locked states of a System object (logical)

`release`

Allow System object property value changes

## Examples

expand all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent `step` syntax. For example, myObject(x) becomes step(myObject,x).

Create a `dsp.SineWave` System object™. Specify that the object generates an exponential output with a complex exponent.

```sine = dsp.SineWave('Frequency',10,... 'ComplexOutput',true,'SamplesPerFrame',128); ```

Create a `dsp.PhaseExtractor` System object™. Specify that the object ignores frame boundaries when returning the unwrapped phase.

```phase = dsp.PhaseExtractor('TreatFramesIndependently',false); ```

Extract the unwrapped phase of a sine wave. Plot the phase versus time using a `dsp.TimeScope` System object™.

```timeplot = dsp.TimeScope('PlotType','Line','SampleRate',1000,... 'TimeSpan',1.5,'YLimits',[0 80],... 'ShowGrid',true,... 'YLabel','Unwrapped Phase (rad)'); for ii = 1:10 sineOutput = sine(); phaseOutput = phase(sineOutput); timeplot(phaseOutput) end ```

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent `step` syntax. For example, myObject(x) becomes step(myObject,x).

Create a `dsp.TransferFunctionEstimator` System object™.

```tfe = dsp.TransferFunctionEstimator('FrequencyRange','centered'); ```

Create a `dsp.PhaseExtractor` System object™. Specify that the object must treat each frame of data independently.

```phase = dsp.PhaseExtractor('TreatFramesIndependently',true); ```

Create a `dsp.IIRFilter` System object™. Compute the transfer function of a third-order IIR filter. Use the `butter` function to generate coefficients for the filter.

```[b,a] = butter(3,.3); iir = dsp.IIRFilter('Numerator',b,'Denominator',a); ```

Extract the phase response of the transfer function. Plot using a `dsp.ArrayPlot` System object™.

```sampleRate = 1e3; phaseplot = dsp.ArrayPlot('PlotType','Line','XOffset',-sampleRate/2,... 'YLimits',[-15 0],... 'YLabel','Phase Response (rad)',... 'XLabel','Frequency (Hz)',... 'Title','System Phase response'); for ii = 1:100 % Generate input input = 0.05*randn(1000,1); % Pass through IIR filter filterOutput = iir(input); % Estimate transfer function transferFunction = tfe(input,filterOutput); % Plot transfer function phase phaseOutput = phase(transferFunction); phaseplot(phaseOutput); end ```

## Algorithms

Consider an input frame of length N:

`$\left(\begin{array}{l}{x}_{1}\\ {x}_{2}\\ ⋮\\ {x}_{N}\end{array}\right)$`

The `step` method acts on this frame and produces this output:

`$\left(\begin{array}{l}{\Phi }_{1}\\ {\Phi }_{2}\\ ⋮\\ {\Phi }_{N}\end{array}\right)$`

where:

`${\Phi }_{i}={\Phi }_{i-1}+\text{angle}\left({x}_{i-1}^{*}{x}_{i}\right)$`

Here, i runs from 1 to N. The `angle` function returns the phase angle in radians.

If the input signal consists of multiple frames:

• If you set `TreatFramesIndependently` to `true`, the `step` method treats each frame independently. Therefore, in each frame, the `step` method calculates the phase using the preceding formula where:

• ${\Phi }_{0}$ is 0.

• ${x}_{0}$ is 1.

• If you set `TreatFramesIndependently` to `false`, the `step` method ignores boundaries between frames. Therefore, in each frame, the `step` method calculates the phase using the preceding formula where:

• ${\Phi }_{0}$ is the last unwrapped phase from the previous frame.

• ${x}_{0}$ is the last sample from the previous frame.