Algo of cordic to find the resultant coordinate not giving desired results on matlab

Status
Not open for further replies.

Mohitkalra0207

Newbie level 3
Joined
Jul 24, 2017
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
33
Hello guys
I am trying to implement cordic algo for finding the final coordinate after specified rotation on matlab using the below mentioned code but I am not getting the required result.Can anyone please suggest me way out??would be very thankful to you.


Code Basic4GL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
xi=.6072
yi=0
q=[45 26.565 14.04 7.125 3.576 1.7899 .8951 .4476 .224 .112 .0558 ]
angle=20
 
for i=0:1:10
    
    if(angle>=0) s=1
    else s=-1
    end
    
    if(i==0)
      x(i+1)= xi - s*1*yi
      y(i+1)= yi + s*1*xi
      angle=angle - s*q(1)
      
    elseif(i<10)
    x(i+1)=x(i) - s*2^(-i)*y(i)
    y(i+1)=y(i) + s*2^(-i)*x(i)
    angle =angle - s*q(i)
    
    end
    
    
    
end 
xcordinate=x(10)
ycordinate=y(10)

 
Last edited by a moderator:

I think you are making a mistake regarding the index of the q vector. For i=0 you have written a separate code using the if statement (this corresponds to the 45 degree angle). When the loop is executed for i=1, the elseif part of the code will be executed but since you are using q(1), again the 45 degree angle will be used. You should have used q(2) in this iteration.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…