cordicrotate
Rotate input using CORDIC-based approximation
Syntax
v = cordicrotate(theta,u)
v = cordicrotate(theta,u,niters)
v = cordicrotate(theta,u,Name,Value)
v = cordicrotate(theta,u,niters,Name,Value)
Description
rotates the input v
= cordicrotate(theta
,u
)u
by theta
using a CORDIC
algorithm approximation. The function returns the result of u
.*
e^(j*theta
).
performs v
= cordicrotate(theta
,u
,niters
)niters
iterations
of the algorithm.
scales
the output depending on the Boolean value, v
= cordicrotate(theta
,u
,Name,Value
)b
.
specifies
both the number of iterations and the v
= cordicrotate(theta
,u
,niters
,Name,Value
)Name,Value
pair
for whether to scale the output.
Input Arguments
|
|
|
|
|
|
|
Default: true |
Output Arguments
|
When the input When the input u is an unsigned integer
or fixed point, the output |
Examples
Run the following code, and evaluate the accuracy of the CORDIC-based complex rotation.
wrdLn = 16; theta = fi(-pi/3, 1, wrdLn); u = fi(0.25 - 7.1i, 1, wrdLn); uTeTh = double(u) .* exp(1i * double(theta)); fprintf('\n\nNITERS\tReal\t ERROR\t LSBs\t\tImag\tERROR\tLSBs\n'); fprintf('------\t-------\t ------\t ----\t\t-------\t------\t----\n'); for niters = 1:(wrdLn - 1) v_fi = cordicrotate(theta, u, niters); v_dbl = double(v_fi); x_err = abs(real(v_dbl) - real(uTeTh)); y_err = abs(imag(v_dbl) - imag(uTeTh)); fprintf('%d\t%1.4f\t %1.4f\t %1.1f\t\t%1.4f\t %1.4f\t %1.1f\n',... niters, real(v_dbl),x_err,(x_err * pow2(v_fi.FractionLength)), ... imag(v_dbl),y_err, (y_err * pow2(v_fi.FractionLength))); end fprintf('\n');
The output table appears as follows:
NITERS Real ERROR LSBs Imag ERROR LSBs ------ ------- ------ ---- ------- ------ ------ 1 -4.8438 1.1800 4833.5 -5.1973 1.4306 5859.8 2 -6.6567 0.6329 2592.5 -2.4824 1.2842 5260.2 3 -5.8560 0.1678 687.5 -4.0227 0.2560 1048.8 4 -6.3098 0.2860 1171.5 -3.2649 0.5018 2055.2 5 -6.0935 0.0697 285.5 -3.6528 0.1138 466.2 6 -5.9766 0.0472 193.5 -3.8413 0.0746 305.8 7 -6.0359 0.0121 49.5 -3.7476 0.0191 78.2 8 -6.0061 0.0177 72.5 -3.7947 0.0280 114.8 9 -6.0210 0.0028 11.5 -3.7710 0.0043 17.8 10 -6.0286 0.0048 19.5 -3.7590 0.0076 31.2 11 -6.0247 0.0009 3.5 -3.7651 0.0015 6.2 12 -6.0227 0.0011 4.5 -3.7683 0.0017 6.8 13 -6.0237 0.0001 0.5 -3.7666 0.0001 0.2 14 -6.0242 0.0004 1.5 -3.7656 0.0010 4.2 15 -6.0239 0.0001 0.5 -3.7661 0.0005 2.2
More About
More About
Algorithms
Extended Capabilities
Version History
Introduced in R2011a