New answers tagged

2

{"sample", "voltage", "length"} /. StringCases[ d, Flatten @ { "sam" ~~ sn : NumberString :> ("sample" -> ToExpression[sn]), m : (NumberString ~~ LetterCharacter ... ~~ #2) :> (# -> QuantityMagnitude[m, #3]) & @@@ { {"voltage", "V", "mV"}, {"length", "m", "nm"}}(*name - base unit - final unit*) } ] {{1, 80.0, 500}, {...


1

You could use Interpreter to extract the quantities with the units preserved. Interpreter["Quantity"] /@ Take[#, -2] & @ StringSplit[#, "_"] & /@ d InputForm @ % (* {{Quantity[80., "Millivolts"], Quantity[500, "Nanometers"]}, {Quantity[450, "Nanometers"], Quantity[300., "Millivolts"]}, {Quantity[1.1, "Volts"], Quantity[6, "Micrometers"]}} *)


4

As was said int the comments, you need to be more explicit to get the forms you want. That means giving a 2nd argument to UnitConvert. For example: UnitConvert[1/Quantity[2.0, "GHz"], "Nanoseconds"] 0.5ns and UnitConvert[1/Quantity[2, "GHz"], "Nanoseconds"] 1/2ns but UnitConvert[1/Quantity[2.0, "GHz"], "Picoseconds"] 500.ps and UnitConvert[1/...


2

You may use the Units & Quantities metric conversions. The quantity system understands metric prefixes, for example "Centi" and "Mega". Therefore you can use TargetUnits if you have Quantity objects for it to convert. A billion in metric prefix is a "Giga". Either the unitless quantity "Unities" or a specific currency like "USDollars" can be used. ...


3

Consider using Charting`FindTicks to avoid manually specifying the plot range. billionticks = Map[ Replace[{n_, lbl_} :> {n, If[n == 0, 0, Row[{"$", lbl/1*^9, "B"}]]}] ] @* Charting`FindTicks[{0, 1}, {0, 1}]; BarChart[<|"Bridgewater AUM" -> 1 10^11, "Softbank Vision Fund" -> 1 10^11|>, Frame -> True, FrameTicks -> {{...


1

yTicks = {#*10^10, If[Mod[#, 2] == 0, "$" <> ToString[10 #] <> "B", ""]} &/@ Range[0, 10, 2]; BarChart[<|"Bridgewater AUM" -> 1 10^11, "Softbank Vision Fund" -> 1 10^11|>, Frame -> True, PlotLabel -> "Assets Under Management", FrameLabel -> Automatic, FrameTicks -> {{yTicks, Automatic}, {Automatic, Automatic}}, ...


Top 50 recent answers are included