by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 2.4, Creation date: 2015-07-31, Last change: 2025-09-14
[x,a]=separateNaN(VL,i)
VL: | List of nan separated sublists | |
i: | optional number of sublist |
x: | List i or number of lists if nargin==1 | |
a: | list of [0 nans size(VL,2)+1] |
how to use
nf=separateNaN(FL); if nf>1; for i=1:nf; PL=separateNaN(FL,i); end;
Example:
VL=[rand(4,3);NaN NaN NaN;rand(2,3)]
[nf,l]=separateNaN(VL)
separateNaN(VL,2)
This function, separateNaN, is designed to handle lists of data that are separated by rows of NaN (Not-a-Number) values. It is part of the SolidGeometry library and was introduced in version 2.4. The function can either return the number of sublists separated by NaN rows or extract a specific sublist based on an optional index parameter.
VL is provided, x is the number of sublists. If both VL and i are provided, x is the sublist at index i.VL plus one.VL is empty. If it is, set x to 0 and a to an empty array, then return.VL and find the indices of NaN rows. Append the size of VL plus one to the list of indices.VL is provided, check the length of the list of indices. If it is 2, set x to 1; otherwise, set x to the number of sublists (length of indices minus one), then return.i is provided, filter out invalid indices (less than 1 or greater than the number of sublists). If the filtered index list is different from the original, issue a warning.i is valid. If not, set x to an empty array and return.i from VL and assign it to x.