Why can't I divide 2 complex numbers with the Divide block in the Fixed-Point Blockset?

29 views (last 30 days)
Why can't I divide 2 complex numbers with the Divide block in the Fixed-Point Blockset?
The Divide Block in the Fixed-Point Blockset gives the following error when I try to divide two complex numbers:
Complex signal mismatch. Input port 1 of block 'test_divide/Divide' expects a signal of numeric type real. However, it is driven by a signal of numeric type complex
However, it is possible to divide two complex numbers using the Product Block in Simulink. It is also possible to multiply two complex numbers using the Product Block in the Fixed-Point Library.
I can divide a complex number by a constant using the Divide Block in the Fixed-Point Library, but I cannot divide two complex numbers.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Dividing by a complex number is not currently supported in the Fixed-Point Blockset.
The implementation of dividing complex numbers in fixed-point is a quite difficult task. There are at least two common ways to divide two complex numbers:
(a+jb)/(c+jd)
One involves the use of trignometric functions such as arctangent, sine, and cosine.
Support for such functions is readily available for workstations, but is often unavailable on embedded fixed point processors because they would consume to much RAM, ROM, and clock cycles.
The other common approach is to multiply numerator and denominator by the complex conjugate of the denominator:
( (a+jb) * (c-jd) )/ ( (c+jd) * (c-jd) ) = ( a*c + b*d - ja*d + jb*c ) / ( c*c + d*d )
Each of these operations, say a*c, needs to be put in some type of temporary variable that has a fixed number of bits and a fixed scaling. Unlike a floating point implementation, the fixed scaling means that an apriori tradeoff of range verses precision must be made. Too much range can destroy the results through precision loss. Too much precision can destroy the results by making overflow likely.
As a workaround, you can build up the calculation using other fixed-point blocks.
For example, each piece of the equation:
( a*c + b*d - ja*d + jb*c ) / ( c*c + d*d )
can be implemented with available blocks such as:
Fixed-Point Sum
Fixed-Point Multiply
Simulink Complex to Re/Im
Simulink Re/Im to Complex
Implementing the equation in pieces allows/requires you to select the data type and scaling of each intermediate variable. This gives you control over the fundamental tradeoffs of range verses precision verses implementation effort.
Our development staff is aware of the request for the capability to divide complex, fixed-point numbers. However, there is no current timeframe for if or when this will be implemented.
[

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!