From: Paul K. <pki...@us...> - 2005-12-30 02:20:39
|
I've added this even though it is not ideal. An ideal solution would allow you to say e.g., "4 kg * 2 m / 8 s" and=20 return a value of "1 kg m/s". I doubt an ideal solution is possible, since math layout is two=20 dimensional, dependent on font and on fine details of spacing between=20 tokens. Even then it is still ambiguous. You could add a units type which is a number, name pair. By writing=20 "4*kg*2*m/(8*s)" with kg,m,s as predefined unit variables the ambiguity=20= goes away. Unfortunately this consumes a large number of desirable=20 variable names such as m and s. Each unit would need multiple versions=20= to allow for every possible standard SI prefix. You could instead rewrite octave's reader to require a comma between=20 matrix elements, and treat a number followed by text as space, but you=20= have approx. zero chance of that patch being accepted. You could write units as a separate type with a constructor that parses=20= string expressions and returns value-unit pairs. Any other suggestions? - Paul On Dec 29, 2005, at 9:35 AM, Carl Osterwisch wrote: > Here's a version with a more impressive demo involving mass. Let me > know if units version 1.0 does not have lb, oz, and kg. > > -Carl > > --- Paul Kienzle <pki...@us...> wrote: > >> For some reason the MacOS 10.3 version of units is missing things >> such >> as >> Pa for pascals (it thinks it is Peta-atto) and J for joules, so the >> demo >> doesn't work very well. I don't know why they use an ancient >> version. >> >> $ units -v >> >> units version 1.0 Copyright (c) 1993 by Adrian Mariano >> >> >> On Dec 28, 2005, at 10:02 AM, Carl Osterwisch wrote: >> >>> Hello, >>> >>> Here is my submission for an octave interface to the GNU units >> program >>> (http://www.gnu.org/software/units) which is immensely useful in >>> engineering calculations to convert from one measurement to >> another. >>> The benefit of using this octave function over hard coded constant >>> conversion factors is cleaner, more maintainable code. >>> >>> I have included demo and test procedures at the bottom. This >> should >>> fit nicely in the "mapping" subdirectory of octave-forge which >> already >>> contains functions to convert between angular measurements. >>> >>> Please let me know if you have any comments or questions. >>> -Carl >>> >>> >>> >>> >>> >>> =09 >>> __________________________________________ >>> Yahoo! DSL =96 Something to write home about. >>> Just $16.99/mo. or less. >>> dsl.yahoo.com >>> <units.m> >> > > > =09 > __________________________________________ > Yahoo! DSL =96 Something to write home about. > Just $16.99/mo. or less. > dsl.yahoo.com > <units.m>= |