connectofmat

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 3.2, Creation date: 2016-12-20, Last change: 2025-09-14

return the element that have a connection in the matrix



See Also: SGanalyzePenetration , CPLsortinout , nearestcluster , nearestpair

Example Illustration

 missing image of connectofmat(CL,n)

Syntax

no=connectofmat(CL,[n])

Input Parameter

CL: Connection matrix
n: input connection value/list; default is ''

Output Parameter

no: vector of all row/vol that are somehow connected to input vector n

Examples


[cind,CC]=CPLsortinout(CPLsample(27)), connectofmat(CC), c=ans




Copyright 2016-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 identify elements in a connection matrix that are connected to a specified input vector. It is part of the SG-Library and was created by Tim Lueth.

Input Parameters

Output Results

Algorithm Steps

  1. Initialize n to an empty string if not provided.
  2. Set k to 0, which will be used as a counter.
  3. If n is empty, perform the following:
    • Initialize nn as a sequence from 1 to the number of rows in CL.
    • Initialize n as a cell array with the same number of rows as CL.
    • While nn is not empty:
      • Increment k.
      • Call connectofmat recursively with the first element of nn.
      • Update nn by removing elements found in the recursive call.
      • Store the result in n{k}.
    • Set no to the first k elements of n.
    • If no output is expected, convert no to a table and display it.
    • Return from the function.
  4. Check if the maximum value in n exceeds the size of CL. If so, throw an error.
  5. Initialize nn as the length of n and ne as the first element of n.
  6. Initialize i to 0.
  7. While i is less than the length of n:
    • Increment i.
    • Find indices in CL where connections exist for the current element of n.
    • Update ne by appending the current element of n.
    • Update n with unique elements found, maintaining order.
  8. Set no to n.
Algorithm explaination created using ChatGPT on 2025-08-19 00:26. (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