主要内容

cordicangle

基于 CORDIC 的相位角

说明

theta = cordicangle(c) 为复数数组 c 的每个元素返回区间 [-π,π] 中的相位角。

示例

theta = cordicangle(c,niters) 执行 niters 次 CORDIC 算法迭代。

示例

全部折叠

使用 cordicangle 函数计算双精度和定点输入的基于 CORDIC 的相位角。

dblRandomVals = complex(rand(5,4),rand(5,4));
theta_dbl_ref = angle(dblRandomVals);
theta_dbl_cdc = cordicangle(dblRandomVals)
theta_dbl_cdc = 5×4

    0.6777    1.4428    1.3512    1.4002
    0.0394    1.2122    0.0328    1.0252
    1.4223    0.6222    0.2816    0.3334
    0.7966    0.6003    0.0948    0.8758
    0.8208    0.1756    0.1208    0.0359

fxpRandomVals = fi(dblRandomVals);
theta_fxp_cdc = cordicangle(fxpRandomVals)
theta_fxp_cdc = 
    0.6777    1.4426    1.3513    1.4001
    0.0393    1.2122    0.0327    1.0254
    1.4224    0.6223    0.2817    0.3333
    0.7964    0.6003    0.0950    0.8757
    0.8208    0.1758    0.1208    0.0359

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13

输入参数

全部折叠

输入数组,指定为标量、向量、矩阵或多维数组。当 c 的元素为非负实数时,cordicangle 返回 0。当 c 的元素为负实数时,cordicangle 返回 π

数据类型: single | double | fi
复数支持:

CORDIC 算法执行的迭代次数,指定为正整数值标量。

增加迭代次数可以得出更准确的结果,但会增加计算开销和延迟。

如果未指定 niters,或者将其指定为空或非有限值,则使用允许的最大值。对于定点输入,最大迭代次数为 c 的字长减 1。对于双精度输入,最大值为 52。对于单精度输入,最大值为 23。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi

输出参量

全部折叠

相位角(以弧度为单位),以标量、向量、矩阵或多维数组形式返回。

如果 c 是浮点类型,则 theta 具有与 c 相同的数据类型。否则,theta 具有与 c 字长相同的定点数据类型,并具有最佳精度小数长度。

算法

全部折叠

参考

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

[2] Andraka, Ray. “A Survey of CORDIC Algorithm for FPGA Based Computers.” In Proceedings of the 1998 ACM/SIGDA Sixth International Symposium on Field Programmable Gate Arrays, 191–200. https://dl.acm.org/doi/10.1145/275107.275139.

[3] Walther, J.S. “A Unified Algorithm for Elementary Functions.” In Proceedings of the May 18-20, 1971 Spring Joint Computer Conference, 379–386. https://dl.acm.org/doi/10.1145/1478786.1478840.

[4] Schelin, Charles W. “Calculator Function Approximation.” The American Mathematical Monthly, no. 5 (May 1983): 317–325. https://doi.org/10.2307/2975781.

扩展功能

全部展开

版本历史记录

在 R2011b 中推出