separateNaN

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

separates List by NaN rows entries

Description

n=separateNaN(VL); for i=1:n; myfunc(separateNaN(VL,i); end;

See Also: lengthNaN , replaceNaN , cellofNaN , selectNaN , uniqueNaN , unsortNaN

Example Illustration

 missing image of separateNaN(VL,i)

Syntax

[x,a]=separateNaN(VL,i)

Input Parameter

VL: List of nan separated sublists
i: optional number of sublist

Output Parameter

x: List i or number of lists if nargin==1
a: list of [0 nans size(VL,2)+1]

Examples

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)




Copyright 2015-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, 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.

Input Parameters

Output Results

Algorithm Steps

  1. Check if VL is empty. If it is, set x to 0 and a to an empty array, then return.
  2. Determine the number of rows in VL and find the indices of NaN rows. Append the size of VL plus one to the list of indices.
  3. If only 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.
  4. If 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.
  5. Check if the index i is valid. If not, set x to an empty array and return.
  6. Extract the sublist at the specified index i from VL and assign it to x.
Algorithm explaination created using ChatGPT on 2025-08-19 01:34. (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