Convert magnitude and/or a phase angle signal to complex signal (2024)

Table of Contents
Description Supported Operations Effect of Out-of-Range Input on CORDIC Approximations Examples Construct Complex Signal from Magnitude and Phase Angle Ports Input |u| — Magnitudescalar | vector | matrix ∠u — Radian phase angle scalar | vector | matrix Port_1 — Magnitude or radian phase angle scalar | vector | matrix Output Port_1 — Complex signalscalar | vector | matrix Parameters Input — Type of input Magnitude (default) | Angle | Magnitude and angle Angle — Phase angle of output 0 (default) | real-valued scalar, vector, or matrix Magnitude — Magnitude of output 0 (default) | real-valued scalar, vector, or matrix Approximation method — CORDIC or none None (default) | CORDIC Number of iterations — Number of iterations for CORDIC algorithm 11 (default) | positive integer, less than or equal to word length of fixed-pointinput Scale output by reciprocal of gain factor — Scale real and imaginary parts of complex output on (default) | off Sample time (-1 for inherited) — Interval between samples -1 (default) | scalar | vector Block Characteristics More About CORDIC References Extended Capabilities C/C++ Code Generation Generate C and C++ code using Simulink® Coder™. HDL Code GenerationGenerate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™. Fixed-Point Conversion Design and simulate fixed-point systems using Fixed-Point Designer™. Version History R2024a: Generate HDL code with fixed-point data types See Also Topics MATLAB-Befehl Americas Europe Asia Pacific References

Convert magnitude and/or a phase angle signal to complex signal

expand all in page

  • Convert magnitude and/or a phase angle signal to complex signal (1)

Libraries:
Simulink / Math Operations
HDL Coder / HDL Floating Point Operations

Description

Supported Operations

The Magnitude-Angle to Complex block converts magnitude and phase angleinputs to a complex output. The angle input must be in rad.

When there are two block inputs, the block supports these combinations of inputdimensions:

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

Effect of Out-of-Range Input on CORDIC Approximations

If you use the CORDIC approximation method [1],the block input for phase angle has these restrictions:

  • For signed fixed-point types, the input angle must fall within the range[–2π, 2π) rad.

  • For unsigned fixed-point types, the input angle must fall within the range[0, 2π) rad.

This table summarizes the effects of an out-of-range input:

Block UsageEffect of Out-of-Range Input
Simulation modesAn error appears.
Generated codeUndefined behavior occurs.

When you use the CORDIC approximation, ensure that you use an in-range input for theMagnitude-Angle to Complex block. Avoid relying on undefinedbehavior for generated code or accelerator modes.

Examples

expand all

Open Model

This example shows how to use the Magnitude-Angle to Complex block to construct a complex-valued signal. You can provide both the magnitude and phase angle as block inputs, or provide one value as an input, and the other on the block dialog box.

Convert magnitude and/or a phase angle signal to complex signal (2)

Ports

Input

expand all

Magnitude, specified as a real-valued scalar, vector, or matrix.

Dependencies

  • To enable this port, set Input toMagnitude and angle.

Limitations

  • If one input has a floating-point data type, the otherinput must use the same data type. For example, both signalsmust be double orsingle.

  • Fixed-point data types are supported only when you set theApproximation method toCORDIC. When one input has afixed-point data type, the other input must also have afixed-point data type.

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

Radian phase angle, specified as a real-valued scalar, vector, ormatrix. To compute the CORDIC approximation, the input angle must bebetween:

  • [–2π, 2π) rad, for signed fixed-point types

  • [0, 2π) rad, for unsigned fixed-point types

For more information, see Effect of Out-of-Range Input on CORDIC Approximations.

Dependencies

  • To enable this port, set Input toMagnitude and angle.

Limitations

  • If one input has a floating-point data type, the otherinput must use the same data type. For example, both signalsmust be double orsingle.

  • Fixed-point data types are supported only when you set theApproximation method toCORDIC. If one input has afixed-point data type, the other input must also have afixed-point data type.

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

Magnitude, or radian phase angle, specified as a real-valued scalar,vector, or matrix.

  • When you set Input toMagnitude, you specify themagnitude at the input port, and the angle on the dialogbox.

  • When you set Input toAngle, you specify the angle atthe input port, and the magnitude on the dialog box.

Dependencies

To enable this port, set Input toMagnitude orAngle.

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

Output

expand all

Complex signal, formed from the magnitude and phase angle youspecify.

If the block input is an array, the output is an array of complexsignals. The elements of a magnitude input vector map to the magnitudesof the corresponding complex output elements. Similarly, the elements ofan angle input vector map to the angles of the corresponding complexoutput elements. If one input is a scalar, it maps to the correspondingcomponent (magnitude or angle) of all the complex output signals.

Data Types: single | double | fixed point

Parameters

expand all

Specify the kind of input: a magnitude input, an angle input, orboth.

Programmatic Use

Block Parameter:Input
Type: character vector
Values:'Magnitude' | 'Angle' | 'Magnitude andangle'
Default:'Magnitude and angle'

Constant phase angle of the output signal, in rad. To compute the CORDIC approximation,the input angle must be between:

  • [–2π, 2π) rad, for signed fixed-point types

  • [0, 2π) rad, for unsigned fixed-point types

For more information, see Effect of Out-of-Range Input on CORDIC Approximations.

Dependencies

To enable this parameter, set Input toMagnitude.

Programmatic Use

Block Parameter:ConstantPart
Type: character vector
Values: constantscalar
Default:'0'

Constant magnitude of the output signal, specified as a real-valuedscalar, vector, or matrix.

Dependencies

To enable this parameter, set Input toAngle.

Programmatic Use

Block Parameter:ConstantPart
Type: character vector
Values:real-valued scalar, vector, ormatrix
Default:'0'

Specify the type of approximation for computing output.

Approximation MethodData Types SupportedWhen to Use This Method
None (default)

Floating point

You want to use the default Taylor seriesalgorithm.

CORDIC

Floating point and fixed point

You want a fast, approximate calculation.

When you use the CORDIC approximation, follow these guidelines for the inputangle:

  • For signed fixed-point types, the input angle must fall within therange [–2π, 2π) rad.

  • For unsigned fixed-point types, the input angle must fall withinthe range [0, 2π) rad.

The block uses the following data type propagation rules:

Data Type of Magnitude InputApproximation MethodData Type of Complex Output

Floating point

None orCORDIC

Same as input

Signed, fixed point

CORDIC

fixdt(1,WL + 2,FL)

where WL andFL are the word lengthand fraction length of the magnitude

Unsigned, fixed point

CORDIC

fixdt(1,WL + 3,FL)

where WL andFL are the word lengthand fraction length of the magnitude

Programmatic Use

Block Parameter:ApproximationMethod
Type: character vector
Values:'None' | 'CORDIC'
Default:'None'

Number of iterations to perform the CORDIC algorithm. The range ofpossible values depends on the data type of the input:

Data Type of Block InputsValue You Can Specify
Floating pointA positive integer
Fixed pointA positive integer that does not exceed the word lengthof the magnitude input or the word length of the phase angleinput, whichever value is smaller

Dependencies

To enable this parameter, set Approximationmethod to CORDIC.

Programmatic Use

Block Parameter:NumberOfIterations
Type: character vector
Values: positive integer, lessthan or equal to word length of fixed-point input
Default:'11'

Select this check box to scale the real and imaginary parts of the complexoutput by a factor of (1/CORDIC gain). This value dependson the number of iterations you specify. As the number of iterations goesup, the value approaches 1.647.

This check box is selected by default, which leads to a more numericallyaccurate result for the complex output, X + iY. However,scaling the output adds two extra multiplication operations, one forX and one for Y.

Dependencies

To enable this parameter, set Approximationmethod to CORDIC.

Programmatic Use

Block Parameter:ScaleReciprocalGainFactor
Type: character vector
Values:'on' | 'off'
Default:'on'

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. For more information, see Specify Sample Time.

Dependencies

This parameter is visible only if you set it to a value other than -1. To learn more, see Blocks for Which Sample Time Is Not Recommended.

Programmatic Use

Block Parameter: SampleTime
Type: string scalar or character vector
Default: "-1"

Block Characteristics

Data Types

double | single

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

More About

expand all

References

[1] Volder, Jack E., “The CORDIC Trigonometric Computing Technique.” IRE Transactions on Electronic Computers EC-8 (1959); 330–334.

[2] Andraka, Ray “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): 191–200.

[3] Walther, J.S., “A Unified Algorithm for Elementary Functions,” Proceedings of the Spring Joint Computer Conference, May 18-20, 1971: 379–386.

[4] Schelin, Charles W., “Calculator Function Approximation,” The American Mathematical Monthly 90, no. 5 (1983): 317–325.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

The Magnitude-Angle to Complex block supports fixed-point and base integer datatypes when you set Approximation method toCORDIC.

Version History

Introduced before R2006a

expand all

Starting in R2024a, you can generate HDL code for Magnitude-Angle to Complex blockthat uses fixed-point data types as inputs. To generate code with fixed-point datatypes, set the Input block parameter to Magnitudeand angle and the Approximation methodparameter to CORDIC. When using the CORDIC approximationmethod, you can also enable Scale output by reciprocal of gainfactor to scale the real and imaginary parts of the complex output bya gain factor.

See Also

Complex to Magnitude-Angle | Complex to Real-Imag | Real-Imag to Complex

Topics

  • Complex Signals

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Convert magnitude and/or a phase angle signal to complex signal (3)

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:

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
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Convert magnitude and/or a phase angle signal to complex signal (2024)

References

Top Articles
Latest Posts
Article information

Author: Kelle Weber

Last Updated:

Views: 5960

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Kelle Weber

Birthday: 2000-08-05

Address: 6796 Juan Square, Markfort, MN 58988

Phone: +8215934114615

Job: Hospitality Director

Hobby: tabletop games, Foreign language learning, Leather crafting, Horseback riding, Swimming, Knapping, Handball

Introduction: My name is Kelle Weber, I am a magnificent, enchanting, fair, joyous, light, determined, joyous person who loves writing and wants to share my knowledge and understanding with you.