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
- CL: The connection matrix, which is a square matrix representing connections between elements.
- n: An optional input connection value or list. If not provided, it defaults to an empty string.
Output Results
- no: A vector of all rows or volumes that are connected to the input vector n.
Algorithm Steps
- Initialize n to an empty string if not provided.
- Set k to 0, which will be used as a counter.
- 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.
- Check if the maximum value in n exceeds the size of CL. If so, throw an error.
- Initialize nn as the length of n and ne as the first element of n.
- Initialize i to 0.
- 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.
- 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