jarvisunits

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - User interface
Introduced first in SolidGeometry 5.1, Creation date: 2022-02-07, Last change: 2025-09-15

parses the list of arguments, try to interprete last argument as unit



See Also:

Example Illustration

 missing image of jarvisunits(args)

Syntax

[fact,mayu,newvar]=jarvisunits([args])

Input Parameter

args: list of arguments

Output Parameter

fact: factor for multiplication such as 1e-3 for 'm' or 1e3 for 'k'
mayu: unit
newvar: new varargin list

Examples


jarvisunits this are 1000 mm
[a,b,c]=jarvisunits( 'this', 'are', '1000', 'mm')




Copyright 2022-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This algorithm is designed to parse a list of arguments and interpret the last argument as a unit, if applicable. It is part of the SolidGeometry library and was introduced in version 5.1.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize a list of units and corresponding factors for conversion.
  2. Check if there are no input arguments. If so, set default values for fact, mayu, and newvar, and return.
  3. Use a permutation vector to create combinations of unit prefixes and base units.
  4. Populate a search table (srchu) with these combinations and their corresponding factors.
  5. Sort the search table by factor and unit name.
  6. Extract the last argument as a potential unit (mayu).
  7. Check if mayu is a recognized unit in the search table. If found, update fact and remove the unit from the argument list.
  8. If no unit is found, set fact to 1 and leave mayu empty.
  9. Return the updated argument list (newvar), the multiplication factor (fact), and the identified unit (mayu).
  10. If no unit is identified, suggest a possible unit based on the last argument.
Algorithm explaination created using ChatGPT on 2025-08-19 08:13. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21