Digital Signal Processing Reference
In-Depth Information
S1 The algorithm then performs N iterations for i
¼
1,
...
, N
1, and performs the following set of
computations:
s
1
¼
1 when
i
>
0 else it is
1
ð
12
:
14a
Þ
x
i þ
1
¼ x
i
s
i
2
i
y
i
ð
12
:
14b
Þ
y
i þ
1
¼ s
i
2
1
x
i
þ y
i
ð
12
:
14c
Þ
i þ
1
¼
i
s
i
tan
1
2
i
ð
12
:
14d
Þ
All the values for tan
1
2
i
are pre-computed and stored in an array.
S2 The final iteration generates the desired results as:
cos
d
¼ x
N
sin
d
¼ y
N
The following MATLAB
code implements the CORDIC algorithm:
% CORDIC implementation for generating sin and cos of desired angle
% theta_d
close all
clear all
clc
% theta resolution that determines number of rotations of CORDIC
% algorithm
N = 16;
% generating a tan table and value of constant k
tableArcTan = [];
k=1;
for i=1:N
k=k*sqrt(1+(2^(-2*i)));
tableArcTan = [tableArcTan atan(2^(-i))];
end
k = 1/k;
x = zeros(1,N+1);
y = zeros(1,N+1);
theta = zeros(1,N+1);
sine = [];
cosine = [];
% Specify all the values of theta
% Theta value must be within -0.9579 and 0.9579 radians
theta_s = -0.9;
theta_e = 0.9;
for theta_d = theta_s:.1:theta_e
% CORDIC algorithm starts here
theta(1) = theta_d;
x(1) = k;
Search WWH ::
Custom Search