angle function in matlab formula
显示 更早的评论
Hi everyone,
I am trying to understand the functionality of angle function of matlab. I am trying to convert my matlab code(which we use for proof of concept) to C++ implementation.
input to angle function - 0.487936206701072 + 0.660466136142335i
output of angle function - 0.934517679414299
I know it must be tan-inverse(img/real) with some other constant.
Please help me with the formula?
回答(1 个)
It's all written in the MATLAB documentation of "angle":
Algorithms
angle takes a complex number z = x + iy and uses the atan2 function to compute the angle between the positive x-axis and a ray from the origin to the point (x,y) in the xy-plane.
Here is the "proof":
format long
z = 0.487936206701072 + 0.660466136142335*1i;
angle(z)
atan2(imag(z),real(z))
7 个评论
Manu Chaudhary
2022-9-22
No, not quite.
Manu Chaudhary
2022-9-23
James Tursa
2022-9-23
编辑:James Tursa
2022-9-23
It is an included function to the standard C++ math library. E.g., here is the C++ code:
#include <cmath>
// some code here to assign real_part and imag_part
result = atan2(imag_part,real_part);
Manu Chaudhary
2022-9-23
类别
在 帮助中心 和 File Exchange 中查找有关 Call C++ from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!