| Contents | Index |
Math Operations
The Magnitude-Angle to Complex block converts magnitude and phase angle inputs to a complex output. The angle input must be in radians.
The block supports the following combinations of input dimensions when there are two block inputs:
Two inputs of equal dimensions
One scalar input and the other an n-dimensional array
If the block input is an array, the output is an array of complex signals. The elements of a magnitude input vector map to the magnitudes of the corresponding complex output elements. Similarly, the elements of an angle input vector map to the angles of the corresponding complex output elements. If one input is a scalar, it maps to the corresponding component (magnitude or angle) of all the complex output signals.
If you use the CORDIC approximation method (see Definitions), the block input for phase angle has the following restrictions:
For signed fixed-point types, the input angle must fall within the range [–2π, 2π) radians.
For unsigned fixed-point types, the input angle must fall within the range [0, 2π) radians.
The following table summarizes what happens for an out-of-range input:
| Block Usage | Effect of Out-of-Range Input |
|---|---|
| Simulation | An error appears. |
| Generated code | Undefined behavior occurs. |
| Accelerator modes |
Ensure that you use an in-range input for the Magnitude-Angle to Complex block when you use the CORDIC approximation. Avoid relying on undefined behavior for generated code or Accelerator modes.
CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is among one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see [1], [2]) The CORDIC algorithm eliminates the need for explicit multipliers. Using CORDIC, you can calculate various functions, such as sine, cosine, arc sine, arc cosine, arc tangent, and vector magnitude. You can also use this algorithm for divide, square root, and hyperbolic, and logarithmic functions.
Increasing the number of CORDIC iterations can produce more accurate results, but doing so also increases the expense of the computation and adds latency.
The block accepts real input signals of the following data types:
Floating point
Fixed point (only when Approximation method is CORDIC)
The following restrictions also apply:
If one input uses a floating-point type, the other input must use the same data type. For example, both signals must be double or single.
If one input uses a fixed-point type, the other input must also use a fixed-point type.
The dialog box for this block appears as follows:

Specify the kind of input: a magnitude input, an angle input, or both.
| Input | What to Specify |
|---|---|
| Magnitude | The constant phase angle of the output signal in radians |
| Angle | The constant magnitude of the output signal |
This parameter is not available when Input is Magnitude and angle.
Specify the type of approximation for computing output.
| Approximation Method | Data Types Supported | When to Use This Method |
|---|---|---|
| None (default) | Floating point | You want to use the default Taylor series algorithm. |
| CORDIC | Floating point and fixed point | You want a fast, approximate calculation. |
When you use the CORDIC approximation, follow these guidelines:
For signed fixed-point types, the input angle must fall within the range [–2π, 2π) radians.
For unsigned fixed-point types, the input angle must fall within the range [0, 2π) radians.
The block uses the following data type propagation rules:
| Data Type of Magnitude Input | Approximation Method | Data Type of Complex Output |
|---|---|---|
Floating point | None or CORDIC | Same as input |
Signed, fixed point | CORDIC | fixdt(1, WL + 2, FL) where WL and FL are the word length and fraction length of the magnitude |
Unsigned, fixed point | CORDIC | fixdt(1, WL + 3, FL) where WL and FL are the word length and fraction length of the magnitude |
Specify the number of iterations to perform the CORDIC algorithm. The default value is 11.
| Data Type of Block Inputs | Value You Can Specify |
|---|---|
| Floating point | A positive integer |
| Fixed point | A positive integer that does not exceed the word length of the magnitude input or the word length of the phase angle input, whichever value is smaller |
Entering a value that is not a positive integer causes an error.
This parameter is available when you set Approximation method to CORDIC.
Select this check box to scale the real and imaginary parts of the complex output by a factor of (1/CORDIC gain). This value depends on the number of iterations you specify. As the number of iterations goes up, the value approaches 1.647.
This check box is selected by default, which leads to a more numerically accurate result for the complex output, X + iY. However, scaling the output adds two extra multiplication operations, one for X and one for Y.
This parameter is available when you set Approximation method to CORDIC.
Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See How to Specify the Sample Time in the online documentation for more information.
Direct Feedthrough | Yes |
Sample Time | Specified by the Sample time parameter |
Scalar Expansion | Yes, of the input when the function requires two inputs |
Dimensionalized | Yes |
Multidimensionalized | Yes |
Zero-Crossing Detection | No |
[1] Volder, J.E. "The CORDIC Trigonometric Computing Technique," IRE Transactions on Electronic Computers. Vol. EC-8, September 1959, pp. 330–334.
[2] Andraka, R. "A survey of CORDIC algorithm for FPGA based computers." Proceedings of the 1998 ACM/SIGDA sixth international symposium on Field programmable gate arrays. Feb. 22–24, 1998, pp. 191–200.

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |