vec2number

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Analytical Geometry
Introduced first in SolidGeometry 4.5, Creation date: 2019-02-06, Last change: 2025-09-14

converst a vector row into a number for vector elemetns of 1 to 9



See Also: , number2vec , digitofnum

Example Illustration

 missing image of vec2number(ord)

Syntax

[z,s]=vec2number(ord)

Input Parameter

ord: vector of integer between 1 and 9

Output Parameter

z: number
s: string of number

Examples


vec2number([1 2 3])
[a,b]=vec2number([1 2 3])




Copyright 2019-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 function, vec2number, converts a vector of integers ranging from 1 to 9 into a single number and its string representation.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize a variable chk to check the validity of the input vector ord.
  2. Calculate chk as the sum of three conditions:
    • Elements of ord less than 1.
    • Elements of ord greater than 9.
    • Elements of ord that are not integers (checked by comparing with their rounded values).
  3. If chk is greater than 0, display a warning that the vector cannot be converted into a single number, and set z to an empty array.
  4. If chk is 0, proceed to convert the vector:
    • Initialize z to 0.
    • Iterate over each element zi in ord:
      • Update z by multiplying it by 10 and adding the current element ord(zi).
    • Initialize s as an empty string.
    • Iterate over each element zi in ord:
      • Convert the current element ord(zi) to a string and append it to s.

Example Usage

Calling vec2number([1 2 3]) will return z = 123 and s = '123'.

Algorithm explaination created using ChatGPT on 2025-08-18 23:08. (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