Unwrap
Unwrap signal phase
Libraries:
DSP System Toolbox /
Signal Operations
Description
The Unwrap block unwraps each channel of the input by adding or subtracting appropriate multiples of 2π to each channel element. The block recognizes phase discontinuities larger than the value of the Tolerance parameter. For more information on phase unwrapping, see Definition of Phase Unwrap.
Examples
Ports
Input
Port_1 — Signal input
scalar | vector | matrix
Signal input to unwrap, specified as a scalar, vector, or matrix. The input must have radian phase entries.
Data Types: single
| double
Output
Port_1 — Signal output
scalar | vector | matrix
Unwrapped signal output, returned as a scalar, vector, or matrix.
The block preserves the input size and dimension, and the output port rate equals the input port rate.
Data Types: single
| double
Parameters
Tolerance (radians) — Jump size
pi
(default) | scalar value
The jump size that the block recognizes as a true phase discontinuity. The default is set to π (rather than a smaller value) to avoid altering legitimate signal features. To increase the block's sensitivity, set the Tolerance to a value slightly less than π.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
Input processing — Method to process the input
Columns as channels (frame
based)
(default) | Elements as channels (sample based)
Specify how the block should process the input. You can set this parameter to one of these options:
Columns as channels (frame based)
(default) — When you select this option, the block treats each column of the input as a separate channel.Elements as channels (sample based)
— When you select this option, the block treats each element of the input as a separate channel.
Reset initial phase to zero for each input frame — Checking successive frames
off
(default) | on
When you clear this parameter, the block ignores boundaries between input frames and does not reset the initial phase value to zero each time a new input is received. In this mode, the block continuously unwraps the data in each column of the input.
This figure illustrates how the block unwraps data when you clear this parameter.
When you select this parameter, the block treats each frame of input data independently and resets the initial phase value for each new input frame.
This figure illustrates how the block unwraps data when you select this parameter.
For more information, see Frame-Based Processing.
Dependencies
To enable this parameter, set the Input
processing parameter to Columns as channels
(frame based)
. In sample-based processing mode, the
block does not reset the initial phase value to zero for each new input.
See Sample-Based Processing for more information.
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
More About
Definition of Phase Unwrap
Phase unwrap or unwrap is a process often used to reconstruct a signal's original phase. Unwrap algorithms add appropriate multiples of 2π to each phase input to restore original phase values, as illustrated in the diagram. For more information on the unwrap algorithm used by this block, see Unwrap Method.
Algorithms that compute the phase of a signal often only output phases between –π and π. For instance, such algorithms compute the phase of sin(2π + 3) to be 3, since sin(3) = sin(2π + 3), and since the actual phase, 2π + 3, is not between –π and π. Such algorithms compute the phases of sin(–4π + 3) and sin(16π + 3) to be 3 as well.
Unwrap Method
The Unwrap block unwraps each channel of its input matrix or input vector by adding 2πk to each successive channel element, and updating k at each phase jump. A phase jump occurs when the difference between two adjacent phase value entries exceeds the value of the Tolerance parameter.
This code shows how the block unwraps the data in a given input channel u.
k=0; % initialize k to 0 i=1; % initialize the counter to 1 alpha=pi; % set alpha to the desired Tolerance. In this case, pi for i = 1:(size(u)-1) yout(i,:)=u(i)+(2*pi*k); % add 2*pi*k to ui if((abs(u(i+1)-u(i)))>(abs(alpha))) %if diff is greater than alpha, increment or decrement k if u(i+1)<u(i) % if the phase jump is negative, increment k k=k+1; else % if the phase jump is positive, decrement k k=k-1; end end end yout((i+1),:)=u(i+1)+(2*pi*k); % add 2*pi*k to the last element of the input
Frame-Based Processing
When you configure the block to perform frame-based processing, by setting the
Input processing parameter to Columns as
channels (frame based)
, the block supports two different unwrap
modes. In both modes, the block adds 2πk to each input channel's
elements, and updates k at each phase discontinuity. The
difference between the two modes is how often the block resets the initial phase
value (k) to zero. You can choose to unwrap data across frame
boundaries (default), or to unwrap only within input frames, by resetting the
initial phase value each time a new input frame is received.
Unwrapping Across Frame Boundaries
In the default mode, the block ignores boundaries between input frames, and continues to unwrap the data in each channel without resetting the initial phase value to zero. To specify this mode, clear the Reset initial phase to zero for each input frame parameter. This figure illustrates how the block unwraps data in this mode.
Unwrapping Within Frames
When you select the Reset initial phase to zero for each input frame parameter, the block treats each frame of input data independently. In this mode, the block resets the initial phase value to zero each time a new input frame is received. This figure illustrates how the block unwraps data in this mode.
Sample-Based Processing
When you configure the block to perform sample-based processing, by setting the
Input processing parameter to Elements as
channels (sample based)
, the block treats each element of the
input as an individual channel. The block unwraps the data in each channel of the
input, and does not reset the initial phase to zero each time a new input is
received. This figure illustrates how the block unwraps data when performing
sample-based processing.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Generated code relies on the memcpy
or
memset
function (string.h
) under certain
conditions.
Version History
Introduced before R2006a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)