Syntax
ART=array2tableTL(AR,[VariableNames])
Input Parameter
AR : | | array |
VariableNames : | | list of variabale names for cols; if 1st element is true => rownames |
Output Parameter
Examples
array2tableTL(rand(2,2),'A','B')
array2tableTL(rand(3,2),true,'A','B','C')
Copyright 2020-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, array2tableTL
, is designed to convert an array into a table format, with options for specifying row or column names. It is a utility function for debugging purposes.
Input Parameters
- AR: This is the input array that you want to convert into a table.
- VariableNames: This is a list of names for the columns of the table. If the first element is a logical
true
, the names are interpreted as row names instead.
Output
- ART: The output is a table with either row or column names as specified.
Algorithm Steps
- Extract the variable names from the input arguments using
varargin
.
- Check if the first element of
nam
is a logical true
:
- If
true
, interpret the remaining elements as row names.
- Check if the number of row names matches the number of rows in
AR
.
- If they do not match, throw an error:
'array2tableTL: Wrong number of row names'
.
- Convert
AR
to a table using array2table
with the specified row names.
- If the first element is not
true
:
- Interpret the elements as column names.
- Check if the number of column names matches the number of columns in
AR
.
- If they do not match, throw an error:
'array2tableTL: Wrong number of column names'
.
- Convert
AR
to a table using array2table
with the specified column names.
Example Usage
array2tableTL(rand(2,2),'A','B')
: Converts a 2x2 random array into a table with column names 'A' and 'B'.
array2tableTL(rand(3,2),true,'A','B','C')
: Converts a 3x2 random array into a table with row names 'A', 'B', and 'C'.
Algorithm explaination created using ChatGPT on 2025-08-19 00:20. (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