to_p - Convert a complex matrix to polar form.
to_p(A) : R = to_p(A) returns in matrix R the magnitudes and angles (in degrees counter-clockwise from the real axis) of the complex numbers in A. The magnitudes and angles are in alternate columns, so R will have twice as many columns as A. R is compatible with to_r(R) for conversion back to rectangular form.
to_p(A,opt) : R = to_p(A,opt) if opt equals 1 this is the same as to_p(A) . If opt equals 2 only the magnitudes are returned. If opt equals 3 only the angles are returned. When opt is equal to 2 or 3 the returned matrix has the same dimensions as A.
[R, Theta] = to_p(A) : The magnitudes are returned in matrix R and the angles in matrix Theta.
The routines to_p() and to_r() make it easy to work with complex numbers in the polar form that is commonly used by electrical engineers (phasor form). Note that there are two "polar forms" that are accepted by the routines. In the first form the complex number magnitudes and angles are in adjacent columns of a single matrix. In the second form the magnitudes and angles are in separate matrices.
When solving systems of equations, all complex matrices should be in rectangular (standard) form. There are no Scilab routines that work with matrices in "polar form". to_p() is normally used to only show the final result of a computation in polar form.
-->// Convert a complex matrix to polar form -->R = to_p([%i 3+4*%i; 0 10; 2+2*%i 5]) R = ! 1. 90. 5. 53.130102 ! ! 0. 0. 10. 0. ! ! 2.8284271 45. 5. 0. ! --> --> -->// Generate random voltage and impedance matrices -->V = 10*rand(3,1)+%i*10*rand(3,1); -->Z = 1000*rand(3,3)+%i*1000*rand(3,3); -->I = Z\V; -->// Display currents in polar form -->to_p(I) ans = ! 0.0215677 64.420226 ! ! 0.0118589 - 78.504668 ! ! 0.0172390 - 177.17102 ! In the last example, we find I1 = 21.6 mA /_ 64.4 degrees, I2 = 11.9 mA /_ -78.5 degress and I3 = 17.2 mA /_ -177.2 degrees.
to_r ,