From octave-sources-request at bevo dot che dot wisc dot edu Mon Jan 27 14:10:28 2003 Subject: kg2mass.m From: Stefan Burger To: octave-sources at bevo dot che dot wisc dot edu Date: Mon, 27 Jan 2003 07:44:25 -0600 --------------Boundary-00=_KVKDBOD5M3GXRBH18X3C Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable --------------Boundary-00=_KVKDBOD5M3GXRBH18X3C Content-Type: text/plain; charset="us-ascii"; name="kg2mass.m" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kg2mass.m" ## Copyright (C) 2003 Stefan Burger ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by the ## Free Software Foundation; either version 2, or (at your option) any ## later version. ## ## Octave is distributed in the hope that it will be useful, but WITHOUT ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, write to the Free ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. ## -*- texinfo -*- ## at deftypefn {Function File} {} kg2mass (@var{unitstr}, @var{val}, @var{metstr}, ) ## Converts kilogram or other SI measures of mass to non-SI or US volume measures . ## ## Input: ## at var{unitstr} : unit to be converted to, ## at var{val} ; Value to be converted, optional, defaults to 1. ## at var{metstr} : unit to be converted from, optional, defaults to 'kg', kilogram. ## ## uses mass2kg, ## see mass2kg for usage, examples and units supported. ## ## at end deftypefn ## at seealso{len2metric, square2metric and vol2metric} ## Author: Stefan Burger ## Description: converts SI mass units (kg) to metric lengths to non-SI mass. function v = kg2mass (unitstr, val, metstr) if (nargin ==1) val = 1.0; metstr = "kg"; %% if no value given, default to one. %% if no metric string given, default to kilogram.. endif if (nargin == 2) metstr = "kg"; elseif (nargin < 1 || nargin > 3 ) usage("kg2mass(unitstr [, val, metstr])"); endif if (! (isstr(unitstr) && isstr(metstr))) usage("len2metric(unitstr [, val, metstr])"); endif %% use mass2kg to do actual conversion calculation. v = val / mass2kg(unitstr, 1, metstr); endfunction --------------Boundary-00=_KVKDBOD5M3GXRBH18X3C--