2

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.

Jamie
  • 31
  • 3
  • 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! – Anne Nov 15 '17 at 21:46
  • 2
    Try "Degree" not "AngularDegrees". – David G. Stork Nov 15 '17 at 21:47
  • You could probably modify the solutions here so that angles are shown in degrees instead of radians. – J. M.'s missing motivation Nov 16 '17 at 01:30
  • @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} – Jamie Nov 16 '17 at 07:20
  • @DavidG.Stork That didn't change anything sadly, tried it before posting here and just double checked. – Jamie Nov 16 '17 at 07:23
  • @J.M. I am guessing you are referring to the last part of that forum part? The part about the presentations package?
    Because that is looking like something in the right direction, but as far as i can see, it is still, even with that, displaying the angle as

    5 ∠ ArcTan[4/3] and i need that part as degrees in the result?

    – Jamie Nov 16 '17 at 07:33
  • I'm not sure I follow what your problem is. If you want to define something in degrees to start, just use 60 Degree. That represents it in radians automatically. Or QuantityMagnitude@ UnitConvert[Quantity[60, "AngularDegrees"], "Radians"]. – b3m2a1 Nov 19 '17 at 21:54
  • @b3m2a1 Defining the vector is not the problem, the problem is displaying it in degrees. As you said yourself, Mathematica automatically represents it in radians, which i can't use for my calculations, i need the representation in degrees. – Jamie Nov 21 '17 at 08:18
  • Divide by Degree to go back to degrees. Or reverse that UnitConvert call: UnitConvert[Quantity[num, "Radians"], "AngularDegrees"] – b3m2a1 Nov 21 '17 at 08:20
  • @b3m2a1 Yea Bill Watts showed me how to do something like that in his answer, but when i use these vector definitions in calculations (even simply adding vector together) the result is weird (as you can see in the latest 2 comments for his answer) when used with units. If you have any knowledge of this, then i would appreciate the help a lot! – Jamie Nov 21 '17 at 10:18

2 Answers2

3

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!

Anne
  • 1,257
  • 9
  • 13
1
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}*)
LCarvalho
  • 9,233
  • 4
  • 40
  • 96
Bill Watts
  • 8,217
  • 1
  • 11
  • 28
  • 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]} – Jamie Nov 19 '17 at 17:36
  • 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?). – Jamie Nov 20 '17 at 11:03
  • 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] – Jamie Nov 20 '17 at 11:03