by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.7, Creation date: 2019-07-08, Last change: 2025-09-14
CPLU=unsortNaN(CPL)
CPL: | Original nan separated list |
CPLU: | Unsorted nan separated list |
CPLsample(13); CPL=ans;
hideingca('text'); unsortNaN(CPL); CPL=ans; textCVL(ans); shg
This algorithm is designed to unsort a NaN-separated list, primarily for testing other NaN functions. It is part of the SolidGeometry library.
separateNaN(CPL) to determine the number of NaN-separated segments in the list CPL. This returns the number of segments n.ELofn(n) to get an array of indices or elements related to the segments.ELunsort() to shuffle or unsort these indices or elements, storing the result in EL.EL into ai, which contains the order in which segments will be selected.CPL using size(CPL,2) and store it in rc.CPLU to store the unsorted list.i from 1 to n:selectNaN(CPL,ai(i)) to select the segment from CPL based on the current index ai(i).CPLU.rc columns to CPLU to maintain separation between segments.CPLU using CPLU=CPLU(1:end-1,:) to ensure the list ends correctly.The function effectively shuffles the order of segments in a NaN-separated list, maintaining the structure but altering the sequence.
Algorithm explaination created using ChatGPT on 2025-08-18 23:37. (Please note: No guarantee for the correctness of this explanation)