MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: plotting equations with units

  • To: mathgroup at
  • Subject: [mg80796] Re: plotting equations with units
  • From: "David Park" <djmpark at>
  • Date: Sun, 2 Sep 2007 02:51:21 -0400 (EDT)
  • References: <fbaqpi$qbs$>

You don't show your particular case, but the simplist method for you might 
be to write a set of rules that set the particular units you have to 1.

For a more general method for handling this I would like to refer you to the 
ExtendUnits package from my web site. (I'm selling the package for $30.) 
Here is the approach I take.

First, I never put units into an equation or symboic definition. Units are 
part of the data. Here is an example. First the symbolic definition and then 
the data.


x[x0_, v0_, a_][t_] := x0 + v0 t + 1/2 a t^2

data = {x0 -> 3 Feet, v0 -> 2 Yard/Second, a -> 5 Meter/Second^2};

Then we can define a plotting function using the Deunitize command in 
ExtendUnits6. The implied units will be in SI, so t will be in Seconds and 
the output will be in Meters. It is also possible to specify implied MKS or 
GCS units.

xplot[t_] = Deunitize[x[x0, v0, a][t] /. data, {t}]

giving:    1143/1250 + (1143 t)/625 + (5 t^2)/2

Plot[xplot[t], {t, 0, 5},
 Frame -> True,
 FrameLabel -> {"t Seconds", "x Meters"}]

There is also a more general routine, DeunitizeWithReference. It allows us 
to give specific implied input and output units. Here is a variation of the 
same case.

x[t_, x0_, v0_, a_] := x0 + v0 t + 1/2 a t^2

Here we specify a deunitized expression where t is given in Minutes, v0 is 
given in Yards/Second and the output will be in Furlongs. x0 and a are given 
explicit values. The routine checks that the specified implied units are 
consistent and it prints a reference expression with the units in it.

xplot[v0_][t_]=DeunitizeWithReference[x[t Minute, 3 Meter, v0 Yard/Second, 

(I omit the reference equation because it doesn't copy and paste neatly.)

giving:   (125 (3 + 9000 t^2 + (6858 t v0)/125))/25146

Here is a plot for v0 = 0 and 100 Yards/Second.

Plot[{xplot[0][t], xplot[100][t]}, {t, 0, 5},
 Frame -> True,
 FrameLabel -> {"t Minutes", "x Furlongs"}]

The package also has the capability of setting up reduced units where 
certain physical constants are set equal to 1 (such as geometric units or 
atomic units) and that is another method for obtaining expressions without 
explicit units.

David Park
djmpark at

"phillman5" <PHILLMAN5 at> wrote in message 
news:fbaqpi$qbs$1 at
> If you have loaded the units package and have used units in your
> equations, is there an easy way to plot the equations?  For the y data
> you can easily divide by the 'units' to get a unitless number
> Plot[eq/units,{x, start,end}]
> but what about the x values?  If they have units, the plot functions
> croaks.  I suppose you can always make a table and use listplot, but
> there should be an easier way.  I have seen some people here with
> packages to download, is there a consensus on the best third part
> solution.  I'd like a universal solution that would work with other
> plotting functions too.
> I am using version 6.

  • Prev by Date: Re: rotating rings illusion
  • Next by Date: Re: Plot, Epilog, and Text
  • Previous by thread: Re: plotting equations with units
  • Next by thread: Re: plotting equations with units