celltype
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.1, Creation date: 2021-11-25, Last change: 2025-09-15
creates any type check for cells - Missing matlab fnct or at least unknown to me
Description
Some matlab function such as startsWith work with cell list bu fail if the type of the cell elements does not fit. Therefor there is a need to check only the elements that fit
See Also: , ismemberincell
Example Illustration
Syntax
celltype(C,tppe)
Input Parameter
C: | | Cell ist |
tppe: | | type tu check such as @ischar or @isnumeric |
Examples
C={1 'asdasd' eye(4)}
celltype(C,@isnumeric)
Copyright 2021-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 a MATLAB function named celltype that checks the type of elements within a cell array. It is designed to verify if each element in the cell array matches a specified type, such as numeric or character.
Input Parameters
- C: A cell array containing elements of various types.
- tppe: A function handle representing the type check, such as
@ischar for character arrays or @isnumeric for numeric arrays.
Algorithm Steps
- Initialize an array
a of the same size as C with false values. This array will store the results of the type checks.
- Iterate over each element in the cell array
C using a loop.
- For each element
C{i}, apply the type check function tppe.
- Store the result of the type check in the corresponding position in the array
a.
- Return the array
a, which contains true for elements that match the specified type and false for those that do not.
Example
Given a cell array C = {1, 'asdasd', eye(4)} and a type check @isnumeric, the function will return an array indicating which elements are numeric.
Algorithm explaination created using ChatGPT on 2025-08-18 23:00. (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