number2vec

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.5, Creation date: 2019-03-26, Last change: 2025-09-14

converst a number into vector of integer



See Also: , vec2number , digitofnum

Example Illustration

 missing image of number2vec(s)

Syntax

vec=number2vec(s)

Input Parameter

s: string or integer scalar

Output Parameter

vec: vector if integer

Examples


number2vec(123)
number2vec('123')




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, number2vec, converts a number into a vector of its individual digits. It is part of the SolidGeometry library and was introduced in version 4.5.

Input Parameters

Output Results

Algorithm Steps

  1. Check if the input s is numeric. If it is, convert it to a string using num2str.
  2. Determine the number of elements in the string representation of s using numel.
  3. Initialize a zero vector vec with the same number of elements as the string.
  4. Iterate over each character in the string:

Example Usage

To convert the number 123 into a vector of digits, you can call the function as follows:

number2vec(123)

Alternatively, if the number is provided as a string:

number2vec('123')
Algorithm explaination created using ChatGPT on 2025-08-18 22:16. (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