Hello,
I have a problem with the atan2 function.
I have 2 programs, one in C and one in Matlab. Both have an identical implementation.
My problem is that I am getting occasionally different values from the atan2 function in C and Matlab.
For instance:
x=0.29695007709080329
y= -0.96764419257510348
Matlab atan2= 2.8438364863237604
C atan2= 2.8438364863237608
So only the last digit is different (and not in all cases), but unfortunately, I would need the values to be identical.
Do you have any ideas it might be like this and how can I solve it?
Thank you.
CD1
0
Newbie Poster
Recommended Answers
Jump to PostMatlab likely guarantees a higher precision than C, and what you're seeing is the round-off errors creeping into the C algorithm.
Jump to PostYou can round to something like six digits in both languages, that would probably be more than sufficient.
All 6 Replies
CD1
0
Newbie Poster
CD1
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
CD1
0
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
CD1
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.