Re: Unit conversion of a list of quantities
- To: mathgroup at smc.vnet.net
- Subject: [mg131974] Re: Unit conversion of a list of quantities
- From: Itai Seggev <itais at wolfram.com>
- Date: Fri, 8 Nov 2013 16:22:44 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
- References: <20131107052837.122DC6A56@smc.vnet.net>
Not possible. UnitConvert has attribute Listable and therefore must work over lists the same way as scalars. Also, it works for me In[5]:= fdep/mass Out[5]= {1.1264*10^-12 J/g,2.672*10^-13 J/g,2.672*10^-13 J/g} In[6]:= UnitConvert[%, "Grays"] Out[6]= {1.1264*10^-9 Gy,2.672*10^-10 Gy,2.672*10^-10 Gy} If it's not working for you, perhaps you somehow entered the unit so that your "g" isn't Grams but some other unit, like g-force. Look at mass//InputForm It should be using "Grams": In[9]:= mass // InputForm Out[9]//InputForm= {Quantity[0.043937500000000004, "Grams"], Quantity[0.06987, "Grams"], Quantity[0.02329, "Grams"]} On Thu, Nov 07, 2013 at 07:27:51AM +0100, mariusz sapinski wrote: > Hi Itai, > Many thanks for your suggestion. For a single quantity it works. It > does not do anything for a list of quantities (see screenshot). > Could it be that UnitConvert cannt take a list as an argument? > Cheers, > Mariusz > > On Thu, Nov 7, 2013 at 6:39 AM, Itai Seggev <[1]itais at wolfram.com> > wrote: > > On Thu, Nov 07, 2013 at 12:28:37AM -0500, mariusz sapinski wrote: > > I have the following lists: > > Edep = {4.9491200000000017`*^-14 Joules, > > 1.8669264000000004`*^-14 Joules, 6.223088000000001`*^-15 Joules} > > mass = {0.043937500000000004` g, 0.06987` g, 0.02329` g} > > > > I want to calculate dose: > > dose = Edep/mass > > > > I get another list (of Quantities): > > > > {(1.1264*10^-12 Joules)/g, (2.672*10^-13 Joules)/g, ( > > 2.672*10^-13 Joules)/g} > > > > OK, but I want to have Grays, ie. Joules/kg: > > > > UnitConvert[dose, "Joules/kg"] > > > > Unfortunately output is not what I want: > > {UnitConvert[(1.1264*10^-12 Joules)/g, "Joules/kg"], > > UnitConvert[(2.672*10^-13 Joules)/g, "Joules/kg"], > > UnitConvert[(2.672*10^-13 Joules)/g, "Joules/kg"]} > > > > > > How to get Mathematica to convert J/g to J/kg? > > Mathematica 9.0.1 on linux. > > > > Regards, Mariusz > Why not just convert to Grays? > In[23]:= Quantity[5, "Joules"/"Grams"]; > In[24]:= UnitConvert[%, "Grays"] > Out[24]= Quantity[5000, "Grays"] > If you wish to convert to J/Kg, you must use correct syntax: > In[25]:= UnitConvert[%, "Joules"/"Kilograms"] > Out[25]= Quantity[5000, ("Joules")/("Kilograms")] > -- > Itai Seggev > Mathematica Algorithms R&D > 217-398-0700 > > References > > 1. mailto:itais at wolfram.com -- Itai Seggev Mathematica Algorithms R&D 217-398-0700
- References:
- Unit conversion of a list of quantities
- From: mariusz sapinski <mariusz.sapinski@gmail.com>
- Unit conversion of a list of quantities