Matlab computes radians from -pi to pi instead of 0 to 2pi

I am working on a problem where the pressure profile should be smooth. For this, the angle should be from 0to 2pi. But when I take the logarithm of some complex numbers, MATLAB displays the angle in piin the negative range pi(clockwise).

For instance:

var_z = [20.0 + 0.6i,  20.0 - 0.6i];
za2 = -2.5000 + 0.5000i;
A = log (-(var_z-za2))   

gives A = [3.11 - 3.13i, 3.11 + 3.091i], but if the angle was only in the counterclockwise direction (i.e. [0, 2pi]), we would get [3.11 + 3.14i, 3.11 + 3.09i].

The latter result makes more sense in my situation, since it prevents the quick jump of pressure profiles. Is there any way to get MATLAB to use 0to 2pito radians?

+4
source share
2

log :

log(abs(z)) + 1i*angle(z)

, "" , 2π-, log:

log(abs(z)) + 1i*mod(angle(z),2*pi)

, :

l = @(z)log(abs(z)) + 1i*mod(angle(z),2*pi);

>> log(-([20.0 + 0.6i,  20.0 - 0.6i]-(-2.5000 + 0.5000i)))

ans =

   3.1135 - 3.1371i   3.1147 + 3.0927i

>> l(-([20.0 + 0.6i,  20.0 - 0.6i]-(-2.5000 + 0.5000i)))

ans =

   3.1135 + 3.1460i   3.1147 + 3.0927i

... , .

+3

0 2pi:

f(x,y)=pi()-pi()/2*(1+sign(x))*(1-sign(y^2))-pi()/4*(2+sign(x))*sign(y)
       -sign(x*y)*atan((abs(x)-abs(y))/(abs(x)+abs(y)))
-1

Source: https://habr.com/ru/post/1689335/


All Articles