Re: [Newbie] Ohm, Ampere, Volt units
- To: mathgroup at smc.vnet.net
- Subject: [mg53450] Re: [mg53426] [Newbie] Ohm, Ampere, Volt units
- From: "David Park" <djmp at earthlink.net>
- Date: Wed, 12 Jan 2005 03:41:22 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Alex, I always like to consider units as well as values to be part of the data. So I would start by defining: data = {r -> 1 Mega Ohm, v -> 1 Milli Volt}; Then with the Unit package you could use... Needs["Miscellaneous`Units`"] i == v/r % /. data MapAt[Convert[#, Nano Ampere] &, %, 2] // N i == v/r i == (Milli*Volt)/(Mega*Ohm) i == Ampere Nano Notice that you have to map Convert to the right hand side of the equation and the answer came out with the prefix after the unit because A sorts before N. If you want to try the V4ExtendUnits package at my web site below we can do a little better. Needs["Miscellaneous`V4ExtendUnits`"] i == v/r % /. data % // ToUnitRule[Ampere, UnitForm -> (PrefixForm[#, 2] &)] i == v/r i == (Milli*Volt)/(Mega*Ohm) i == 1.0 Nano Ampere ToUnit and ToUnitRule replace Convert. ToUnitRule automatically maps to the rhs. The UnitForm option allows you to specify the output form of the number (say with NumberForm or EngineeringForm) but in this case we used PrefixForm, which automatically picks the proper prefix for the quantity and puts the quantity in a HoldForm so that the prefix actually is a prefix. The package also allows you to install new units, or synonyms for units. So we could install a new unit nAmp for a nano Ampere. InstallNewUnit[nAmp -> Nano Ampere] i == v/r % /. data % // ToUnitRule[nAmp] i == v/r i == (Milli*Volt)/(Mega*Ohm) i == 1. nAmp David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Alexander Groß [mailto:PLEASEAlexanderGrossREMOVETHIS at gmx.de] To: mathgroup at smc.vnet.net Hi everyone, me (a Mathematica beginner) was trying to let Mathematica do the work. I have a very simple equation which I want Mathematica to solve and compute units. Resistor = 1 Mega Ohm; Voltage = 1 Milli Volt; Current = Voltage / Resistor Mathematica displays the solution of current in [Milli Volt] / [Mega Ohm]. That's not what I would like to see. I would like to resolve the units as follows: [Milli Volt] / [Mega Ohm] = [Milli Volt]/ [Mega [Volt / Ampere]] = [Nano Ampere] I tried the Convert[] function to achieve the desired output, but in vain. Does anybody know how to tell Mathematica to display Ampere? Thanks for your time and help. Best regards, Alex -- _______________________________________ Alexander Groß Dipl.-Ing. (BA) für Informationstechnik PLEASEAlexanderGrossREMOVETHIS at gmx.de http://www.it99.org/axl ICQ# 36765668 _______________________________________