cordiccexp
CORDIC-based approximation of complex exponential
Description
Examples
Effect of Number of Iterations on CORDIC Approximation
See the effect of the number of iterations on the result of the cordiccexp
approximation.
wl = 8; theta = fi(pi/2,1,wl); output_type = fi([], 1,wl,wl - 2); results_array = zeros(wl - 1,1,'like',output_type)'; for niters = 1:(wl - 1) cis = cordiccexp(theta,niters); fl = cis.FractionLength; x = real(cis); y = imag(cis); x_dbl = double(x); y_dbl = double(y); x_err = abs(x_dbl - cos(double(theta))); y_err = abs(y_dbl - sin(double(theta))); result = [niters,y_dbl,y_err,(y_err*pow2(fl)),... x_dbl,x_err,(x_err*pow2(fl))]; results_array = [results_array; result]; end results_table = array2table(results_array,'VariableNames',{'NITERS',... 'Y (SIN)','Y ERROR','Y LSBs','X (COS)','X ERROR','X LSBs'})
results_table=8×7 table
NITERS Y (SIN) Y ERROR Y LSBs X (COS) X ERROR X LSBs
______ _______ ________ ______ ________ ________ _______
0 0 0 0 0 0 0
1 0.70312 0.29688 1.9844 -0.70312 0.70312 1.9844
1.9844 0.9375 0.0625 1.9844 -0.3125 0.3125 1.9844
1.9844 0.96875 0.03125 1.9844 -0.0625 0.0625 1.9844
1.9844 0.96875 0.03125 1.9844 0.0625 0.0625 1.9844
1.9844 0.98438 0.015625 1 0 0 0.46875
1.9844 0.98438 0.015625 1 0.03125 0.03125 1.9844
1.9844 1 0 0 0.015625 0.015625 1.4688
Input Arguments
theta
— Input array
scalar | vector | matrix | multidimensional array
Input array, specified as a signed or unsigned scalar, vector, matrix, or
multidimensional array. All values of theta
must be real and in the
range [-2π 2π)
.
If the input is a fi
object, it must use binary-point
scaling.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
niters
— Number of iterations CORDIC algorithm performs
positive scalar integer
Number of iterations the CORDIC algorithm performs, specified as a positive scalar integer. Increasing the number of iterations can produce more accurate results but also increases the expense of the computation and adds latency.
If you do not specify niters
, or if you specify a value that is
too large, the algorithm uses a maximum value based on the data type of the inputs:
Fixed-point inputs — The maximum number of iterations is one less than the word length of
theta
.Floating-point inputs — The maximum value is
52
fordouble
or23
forsingle
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
Output Arguments
y
— Approximated complex exponential
scalar | vector | matrix | multidimensional array
Approximated complex exponential
e^(j*theta
), returned as a
scalar, vector, matrix, or multidimensional array. The data type of the output depends
on the input:
When the input
theta
is floating point, the output data type is the same as the input type.When the input
theta
is fixed point, the output has the same word length as the input and a fraction length equal to the word length minus 2.
More About
CORDIC
CORDIC is an acronym for COordinate Rotation DIgital Computer. The Givens rotation-based CORDIC algorithm is one of the most hardware-efficient algorithms available because it requires only iterative shift-add operations (see References). 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, hyperbolic, and logarithmic functions.
Increasing the number of CORDIC iterations can produce more accurate results, but doing so increases the expense of the computation and adds latency.
More About
Algorithms
Signal Flow Diagrams
X represents the real part, Y represents the
imaginary part, and Z represents theta
. The
accuracy of the CORDIC rotation kernel depends on the choice of initial values for
X, Y, and Z. This algorithm
uses these initial values:
z0 is initialized to the θ input argument value.
x0 is initialized to 1/AN.
y0 is initialized to 0.
fimath
Propagation Rules
CORDIC functions discard any local fimath
attached to the
input.
The CORDIC functions use their own internal fimath
when performing calculations:
OverflowAction
—Wrap
RoundingMethod
—Floor
The output has no attached fimath
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Variable-size signals are not supported.
The number of iterations the CORDIC algorithm performs,
niters
, must be a constant.
HDL Code Generation
Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.
The cordiccexp
function also supports MATLAB® to High-Level Synthesis (HLS) code generation.
Version History
Introduced in R2010a
See Also
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 (한국어)