2
$\begingroup$

This may prove to be simple, but i have not been able to figure it out (nor am i sure if it can even be done in Mathematica).

I use vectors in electrical engineering as a polar, length and angle (in degrees). But Mathematica insist on displaying vectors in polar as a length and angle (in radians or something) and i need the degrees for my results.

URg = AngleVector[{UnitConvert[I*Rg, "Volts"], 
   Quantity[30, "AngularDegrees"]}]
{Quantity[2.07846, "Volts"], Quantity[1.2, "Volts"]}

I have tried something like this, but as far as i can see and understand, the program recognizes the degrees in the formula, but won't display it as degrees in the result.

I looked up function like ToPolarCoordinates, but it still doesn't work properly.

Hooping someone has some guidance or at least some good suggestions.

In advance thank you.

$\endgroup$
  • $\begingroup$ I'm not totally sure I understand the problem. From what I understand, AngleVector[{r,theta}] gives the Cartesian coordinates of the polar coordinate {r,theta}, so to get the angle "back", one would have to do something like N[ArcTan @@ (QuantityMagnitude@URg)/Degree]. Please correct me if I've misunderstood, though! $\endgroup$ – Anne Nov 15 '17 at 21:46
  • 2
    $\begingroup$ Try "Degree" not "AngularDegrees". $\endgroup$ – David G. Stork Nov 15 '17 at 21:47
  • $\begingroup$ You could probably modify the solutions here so that angles are shown in degrees instead of radians. $\endgroup$ – J. M.'s discontentment Nov 16 '17 at 1:30
  • $\begingroup$ @Anne That way i can calculate the angle afterwards yea, but i want the initial definition to recognize the angle in degrees Something like this {Quantity[2.07846, "Volts"] \[Angle] Quantity[30, "AngularDegrees"]} Basiclly i need the polar coordinates displayed as {r,Degree} $\endgroup$ – Jamie Nov 16 '17 at 7:20
  • $\begingroup$ @DavidG.Stork That didn't change anything sadly, tried it before posting here and just double checked. $\endgroup$ – Jamie Nov 16 '17 at 7:23
3
$\begingroup$

Putting this in an answer for space/formatting capabilities.

If you're starting with some complex number, say $z=1+i\sqrt{3}$ for example, AbsArg will get you the polar representation of $z$ (in radians):

z = 1 + Sqrt[3]*I;
AbsArg[z]

(*{2, \[Pi]/3}*)

You can then convert this to degrees (many ways to do this of course):

zpolar = MapAt[#*180/Pi &, AbsArg[z], 2]

(*{2, 60}*)

If you want the end results to be "Quantities":

MapThread[Quantity, {zpolar, {"Volts", "AngularDegrees"}}]

(*{Quantity[2, "Volts"], Quantity[60, "AngularDegrees"]}*)

You can also do something similar if you use Quantities in your z, I believe.

Hopefully this is something along the lines of what you had in mind!

| improve this answer | |
$\endgroup$
1
$\begingroup$
vec={4,5};

{r, Theta} = ToPolarCoordinates[vec]
(*{Sqrt[41],ArcTan[5/4]}*)

polarvec = {r, N[Theta]/°}
(*{Sqrt[41],51.3401}*)

Now your vector is in {r, theta} with theta in degrees.

If you want to add two vectors, or do about any other operations on them, Mathematica really wants the vector in rectangular coordinates. Kind of kludgy, but you can do something like:

polarURG = {2.4  V, 30 °}
polarUXL = {4.8 V, 60 °}

$Assumptions = V > 0

(FromPolarCoordinates[polarURG] + FromPolarCoordinates[polarUXL]) // 
  ToPolarCoordinates[#] & // Simplify
PolarSum = {%[[1]], N[%[[2]]]/°}

(*{6.982350 V,0.874478}*)
(*{6.9823509 V,50.103909}*)
| improve this answer | |
$\endgroup$
  • $\begingroup$ Okay, so i got that to work for the most part. But i ran into the problem, that with having to different vectors defined this way, i couldn't get mathematica to add them togehter as vectors? it just adds the values togehter as in polarURg={2.4V,30\[Degree]}; polarUXL={4.8V,60\[Degree]}; Esys=polarURg+polarUXL; Esys={7.2V,90\[Degree]} $\endgroup$ – Jamie Nov 19 '17 at 17:36
  • $\begingroup$ So this mostly works, but it seems like i can't use Quantity values this way? I am guessing that it's because of the $Assumption=V>0 which i tried to use as $Assumption="Volts">0, but i don't fully understand what this is supposed to do (i believe it is used for the simplify function?). $\endgroup$ – Jamie Nov 20 '17 at 11:03
  • $\begingroup$ I have it setup as polarURg={Quantity[2.4,"Volts"],30\[Degree]} polarUXL={Quantity[4.8,"Volts"],60\[Degree]} $Assumption="Volts">0 and this gives me {Quantity[6.98235, "Volts"], ArcTan[Quantity[4.47846, "Volts"], Quantity[5.35692, "Volts"]]} and Quantity[6.98235, "Volts"], ArcTan[Quantity[4.47846, "Volts"], Quantity[5.35692, "Volts"]]/\[Degree] $\endgroup$ – Jamie Nov 20 '17 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.