by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.9, Creation date: 2020-02-08, Last change: 2025-09-14
See Also:
[ic,err,ia]=finduniqueVL(NVL,VL,[tol,warn])
NVL: | vector row list to search in | |
VL: | vector row list to search for | |
tol: | tolerance for warning; default is 1e-12 | |
warn: | if true; warnings are shown; default is true |
ic: | list of index entries; 3rd result of unique | |
err: | deviation between VL and best fit in NVL | |
ia: | list of index entries; 2nd result of unique |
finduniqueVL(rand(10,3),rand(6,3))
X=rand(10,3); X=[X(1:5,:);X(3,:); X(1,:);X(6:end,:)]
[ic,err,ia]=finduniqueVL(X,X) % identical mapping
[ic,err,ia]=finduniqueVL(X,X+1e-3) % warning since thr= 1e-12
[ic,err,ia]=finduniqueVL(X,X+1e-3,0.01) % No warning since thr= 0.01
This function, finduniqueVL, is designed to find unique vector rows in a list with a specified tolerance. It is more reliable than the standard unique function.
1e-12.true.NVL for each row in VL.VL and its best fit in NVL.ic.tol and warn using getfuncparams to handle optional parameters.ic and err as NaN arrays with the same number of rows as VL.VL:
NVL using vecnormr.ic.err.tol and warn is true, display a warning.ia as the unique indices from ic.Here are some examples of how to use the function:
finduniqueVL(rand(10,3),rand(6,3)): Finds unique rows in a random matrix.[ic,err,ia]=finduniqueVL(X,X): Identical mapping with no warnings.[ic,err,ia]=finduniqueVL(X,X+1e-3): Generates a warning due to the default tolerance.[ic,err,ia]=finduniqueVL(X,X+1e-3,0.01): No warning due to increased tolerance.