[Date Index]
[Thread Index]
[Author Index]
Re: plotting equations with units
*To*: mathgroup at smc.vnet.net
*Subject*: [mg80796] Re: plotting equations with units
*From*: "David Park" <djmpark at comcast.net>
*Date*: Sun, 2 Sep 2007 02:51:21 -0400 (EDT)
*References*: <fbaqpi$qbs$1@smc.twtelecom.net>
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.
Needs["Units6`ExtendUnits6`"]
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.
Clear[x];
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.
Clear[xplot];
xplot[v0_][t_]=DeunitizeWithReference[x[t Minute, 3 Meter, v0 Yard/Second,
5Meter/Second^2],{t,v0},Furlong]
(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 comcast.net
http://home.comcast.net/~djmpark/
"phillman5" <PHILLMAN5 at gmail.com> wrote in message
news:fbaqpi$qbs$1 at smc.twtelecom.net...
> 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**
| |