From octave-sources-request at bevo dot che dot wisc dot edu Mon Jan 27 14:10:46 2003 Subject: metric2area.m From: Stefan Burger To: octave-sources at bevo dot che dot wisc dot edu Date: Mon, 27 Jan 2003 07:44:33 -0600 --------------Boundary-00=_MVKDNKQKA117M68NH7KB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable --------------Boundary-00=_MVKDNKQKA117M68NH7KB Content-Type: text/plain; charset="us-ascii"; name="metric2area.m" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="metric2area.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} {} metric2area (@var{unitstr}, @var{val}, @var{metstr}) ## Converts metric measures to non-SI or US area 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 'm', meters. ## ## uses area2metric, ## see area2metric for usage, examples and units supported. ## ## at end deftypefn ## at seealso{len2metric, area2metric and vol2metric} ## Author: Stefan Burger ## Description: converts metric lengths to non-SI lengths. function v = metric2area (unitstr, val, metstr) if (nargin ==1) val = 1.0; metstr = "m2"; %% if no value given, default to one. %% if no metric string given, default to meters squared. endif if (nargin == 2) metstr = "m2"; %% if not specified, default to meters squared. elseif (nargin < 1 || nargin > 3 ) usage("metric2area(unitstr [, val, metstr])"); endif if (! (isstr(unitstr) && isstr(metstr))) usage("metric2area(unitstr [, val, metstr])"); endif %% use area2metric to do actual conversion calculation. %% A bit of an overhead to use function calling instead %% of direct conversion, but makes for better consistency, %% maintenance and error detection. v = val / area2metric(unitstr, 1, metstr); endfunction --------------Boundary-00=_MVKDNKQKA117M68NH7KB--