by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Text/Strs/Chars/Links
Introduced first in SolidGeometry 4.6, Creation date: 2019-05-24, Last change: 2025-09-14
See Also: fprintfvec
, str2codelines
, sprintfvec
fprintfvec2([f,s,X])
f: | file pointer; default is '' | |
s: | format string | |
X: | number |
fprintfvec2('%.3f',[1 2 3; 4 5 6])
This function, fprintfvec2, is designed to print vectors in a format suitable for code generation. It is part of the SolidGeometry library and was introduced in version 4.6.
getfuncparams function. It assigns default values if parameters are not provided.X, sets s to '%d', and f to an empty string.f is a character string, it assigns s to f, X to s, and f to an empty string.sfmt1 and sfmt2, are created using sprintf to format the output.X to print each element using the specified format. It uses sfmt1 for all but the last element in a row and sfmt2 for the last element.To print a matrix with three decimal places, you can use:
fprintfvec2('%.3f', [1 2 3; 4 5 6])
This will output:
[ 1.000, 2.000, 3.000; 4.000, 5.000, 6.000; ]
Algorithm explaination created using ChatGPT on 2025-08-18 23:57. (Please note: No guarantee for the correctness of this explanation)