Syntax
[fact,mayu,newvar]=jarvisunits([args])
Input Parameter
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
- args: A list of arguments that may include a unit as the last element.
Output Results
- fact: A multiplication factor corresponding to the unit, such as 1e-3 for 'm' (millimeters) or 1e3 for 'k' (kilometers).
- mayu: The unit identified from the arguments.
- newvar: The new list of arguments with the unit removed, if a unit was identified.
Algorithm Steps
- Initialize a list of units and corresponding factors for conversion.
- Check if there are no input arguments. If so, set default values for fact, mayu, and newvar, and return.
- Use a permutation vector to create combinations of unit prefixes and base units.
- Populate a search table (srchu) with these combinations and their corresponding factors.
- Sort the search table by factor and unit name.
- Extract the last argument as a potential unit (mayu).
- Check if mayu is a recognized unit in the search table. If found, update fact and remove the unit from the argument list.
- If no unit is found, set fact to 1 and leave mayu empty.
- Return the updated argument list (newvar), the multiplication factor (fact), and the identified unit (mayu).
- 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