Message Boards Message Boards

0
|
5874 Views
|
1 Reply
|
2 Total Likes
View groups...
Share
Share this post:

Use shorter notation to work with units?

Posted 5 years ago

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!

POSTED BY: Sascha Tayefeh

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"] *)
POSTED BY: Tim Laska
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