lengthNaN

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 4.3, Creation date: 2018-10-16, Last change: 2025-09-14

returns the length of the individiual entries of a nan separated list



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

Example Illustration

 missing image of lengthNaN(CPL)

Syntax

[l,a]=lengthNaN(CPL)

Input Parameter

CPL: nan separated list

Output Parameter

l: length of the individual segments of the nan separated list
a: starting indices

Examples


loadweb CAD_pictures.mat; imshow(CADpictservo);
CPLofimage(CADpictservo); CPL=ans;
selectNaN(CPL,find(lengthNan(CPL)>300));
[a,b]=lengthNaN(CPLsample(11))




Copyright 2018-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 algorithm is designed to process a NaN-separated list, which is a list where segments are separated by NaN (Not-a-Number) values. The function lengthNaN calculates the length of each segment and provides the starting indices of these segments.

Input Parameters

Output Results

Algorithm Steps

  1. Find the indices of NaN values in the first column of CPL using find(isnan(CPL(:,1))).
  2. Append the size of CPL plus one to the list of NaN indices to handle the end of the list.
  3. Calculate the lengths of each segment by taking the difference between consecutive NaN indices and store them in l.
  4. Subtract one from each length to account for the NaN separator itself.
  5. Determine the starting indices of each segment by taking the indices of the first element of each segment and store them in a.

Example Usage

In the example provided, a CAD image is loaded, and a NaN-separated list is created from it. The function lengthNaN is then used to find segments longer than 300 units.

Algorithm explaination created using ChatGPT on 2025-08-18 23:41. (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