Syntax
nr=numofstrtab(tok,strtab)
Input Parameter
tok : | | string to compare with; |
strtab : | | cell list; frist col = string |
Output Parameter
nr : | | cell list row, col 2: end |
Examples
strtab={'spine',1; 'torso',2; 'carm', 3;'table',4};
numofstrtab ('TORSO',strtab);
Copyright 2017-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, numofstrtab
, is designed to find a specific row in a cell array of strings based on a given token. It returns the contents of the second column of the matched row.
Input Parameters
- tok: A string to compare with the first column of the cell array. It can also be a numeric value.
- strtab: A cell array where the first column contains strings and the second column contains associated values.
Output Results
- nr: The value(s) from the second column of the row where the first column matches the token. If no match is found and
tok
is numeric, nr
will be set to tok
.
Algorithm Steps
- Initialize
nr
as an empty array.
- Iterate over each row of
strtab
using a for-loop.
- For each row, compare the first column string with the lowercase version of
tok
using isequal
.
- If a match is found, set
nr
to the contents of the second column of that row and exit the loop.
- After the loop, if
nr
is still empty and tok
is numeric, set nr
to tok
.
Example
Given the cell array strtab={'spine',1; 'torso',2; 'carm', 3;'table',4}
and the token 'TORSO'
, the function will return 2
as it matches the second row.
Algorithm explaination created using ChatGPT on 2025-08-18 22:33. (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