基于cordic的正弦和余弦近似
[
y
,x
] = cordicsincos(θ,硝石)
|
|
|
|
|
基于cordici的近似正弦 |
|
基于cordics的近似余弦 |
实例的结果中迭代次数的影响cordicsincos
近似。
wrdLn = 8;= fi(pi/ 2,1, wrdLn);fprintf('\n\nNITERS\t\tY (SIN)\t ERROR\t LSBs\t tX (COS)\t ERROR\t LSBs\n');流(' - \ \ t - \ t - \ t - \ \ t——\ t——\ \ n”);对于niters = 1:(wrdLn - 1) [y, x] = cordicsincos(theta, niters);y_FL = y.FractionLength;y_dbl =双(y);x_dbl =双(x);Y_err = abs(y_dbl - sin(double(theta)));X_err = abs(x_dbl - cos(double(theta))); fprintf(' %d\t\t%1.4f\t %1.4f\t %1.1f\t\t%1.4f\t %1.4f\t %1.1f\n', ... niters, y_dbl,y_err, (y_err * pow2(y_FL)), x_dbl,x_err, ... (x_err * pow2(y_FL))); end fprintf('\n'); |
输出表如下所示:
硝石Y(罪)错误lsb X lsb (COS)错误 ------ ------- ------ ---- ------- ------ ---- 2 1 0.7031 0.2968 19.0 0.7031 0.7105 45.5 0.9375 0.0625 4.0 0.3125 0.3198 20.5 3 4 0.9844 0.0156 1.0 0.0938 0.1011 6.5 0.9844 0.0156 1.0 -0.0156 0.0083 0.5 5 6 1.0000 0.0000 0.0 0.0312 0.0386 2.5 1.0000 0.0000 0.0 1.0000 0.0000 0.0 0.0156 0.0000 0.0073 0.5 70.0230 1.5