Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

One of the big things Wolfram touted about their new mathematica 9 was its ability to format units, and do calculations with them. I however can't seem to find out how to actually use them to convert. For example. I calculate an area in square angstroms, and I want to convert that quantity to square meters in this bit of code. I can't convert to square meters.

molesArgon = V/ (R*T) /. {V -> 25.6051, R ->  82.05746, T -> 273.15};
argonAtoms = molesArgon*6.022*10^23;
area = Quantity[3.14*(0.95)^2, "Square Angstroms"]
experimentalArea = (UnitConvert[area, 
    "\!\(\*SuperscriptBox[\(meters\), \(2\)]\)"]*argonAtoms)

gives this output

6.87936*10^20 UnitConvert[Quantity[2.83385, ("Angstroms")^2], 
"\!\(\*SuperscriptBox[\(meters\), \(2\)]\)"]

and an error

 "UnitConvert::unkunit: "Unable to interpret unit specification \!\(\*\"\\\"\!\(\*SuperscriptBox[\(meters\), \(2\)]\)\\\"\"\)""
share|improve this question
    
There's something messed-up in the meters squared string. If you simply write experimentalArea = UnitConvert[area, "Meters"^2]*argonAtoms everything seems to work OK. –  Sjoerd C. de Vries Apr 21 '13 at 19:01
add comment

closed as too localized by Sjoerd C. de Vries, whuber, m_goldberg, Yves Klett, J. M. Apr 22 '13 at 9:42

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Why not use Square Meters just like you used Square Angstroms? e.g.:

UnitConvert[Quantity[2*^10, "Square Angstroms"], "Square Meters"]

Gives:

1/5000000000 ((m)^2)
share|improve this answer
add comment

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