Message Boards Message Boards

GROUPS:

Use shorter notation to work with units?

Posted 2 years ago
3027 Views
|
1 Reply
|
2 Total Likes
|

Hi all

This works as expected:

in: Quantity[18, "Meters"] + Quantity[12,"cm"]
out: Quantity[1812, "Centimeters"]  

However, I'd prefer a shorter notation like this, which also works as expected:

in: 18 meters + 20 meters
out: 38 meters

But the following does not work as expected:

in: 18 meters + 20 centimeters
out: 20 centimeters + 18 meters

Any suggestions?

Thanks!

Hi Sascha,

You may want to take a quick look at my post to this discussion that shows how unit discovery can be used to create shorthand notation fairly painlessly . For example, you could use ctrl+= to define meters and centimeters or just do it by hand like so

m = Quantity[1, "Meters"];
cm =  m /100;
18 m + 20 cm // N 
(* Quantity[18.2, "Meters"] *)
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract