mp_table

class mp_table

mp_table - Very basic table-compatible class for Octave or older Matlab.

T = mp_table(var1, var2, ...);
T = mp_table(..., 'VariableNames', {name1, name2, ...}});
T = mp_table(..., 'RowNames', {name1, name2, ...}});
T = mp_table(..., 'DimensionNames', {name1, name2, ...}});

Implements a very basic table array class focused the ability to store and access named variables of different types in a way that is compatible with MATLAB’s built-in table class. Other features, such as table joining, etc., are not implemented.

Important

Since the dot syntax T.<var_name> is used to access table variables, you must use a functional syntax <method>(T,...), as opposed to the object-oriented T.<method>(...), to call mp_table methods.

mp_table Methods:

See also table.

Constructor Summary
mp_table(varargin)

Constructs the object.

T = mp_table(var1, var2, ...)
T = mp_table(..., 'VariableNames', {name1, name2, ...})
T = mp_table(..., 'RowNames', {name1, name2, ...})
T = mp_table(..., 'DimensionNames', {name1, name2, ...})
Method Summary
istable()

Returns true.

TorF = istable(T)

Unfortunately, this is not really useful until Octave implements a built-in istable() that this can override.

size(dim)

Returns dimensions of table.

[m, n] = size(T)
m = size(T, 1)
n = size(T, 2)
isempty()

Returns true if the table has no columns or no rows.

TorF = isempty(T)
end(k, n)

Used to index the last row or column of the table.

last_var = T{:, end}
last_row = T(end, :)
subsref(s)

Called when indexing a table to retrieve data.

sub_T = T(i, *)
sub_T = T(i1:iN, *)
sub_T = T(:, *)
sub_T = T(*, j)
sub_T = T(*, j1:jN)
sub_T = T(*, :)
sub_T = T(*, <str>)
sub_T = T(*, <cell>)
var_<name> = T.<name>
val = T.<name>(i)
val = T.<name>(i1:iN)
val = T.<name>{i}
val = T.<name>{i1:iN}
val = T.<name>(*, :)
val = T.<name>(*, j)
var_<j> = T{:, j}
var_<str> = T{:, <str>}
val = T{i, *}
val = T{i1:iN, *}
val = T{:, *}
val = T{*, j}
val = T{*, j1:jN}
val = T{*, :}
val = T{*, <str>}
val = T{*, <cell>}
subsasgn(s, b)

Called when indexing a table to assign data.

T(i, *) = sub_T
T(i1:iN, *) = sub_T
T(:, *) = sub_T
T(*, j) = sub_T
T(*, j1:jN) = sub_T
T(*, :) = sub_T
T(*,  <str>) = sub_T
T(*,  <cell>) = sub_T
T.<name> = val
T.<name>(i) = val
T.<name>(i1:iN) = val
T.<name>{i} = val
T.<name>{i1:iN} = val
T.<name>(*, :) = val
T.<name>(*, j) = val
T{:, j} = var_<j>
T{:, <str>} = var_<str>
T{i, *} = val
T{i1:iN, *} = val
T{:, *} = val
T{*, j} = val
T{*, j1:jN} = val
T{*, :} = val
T{*, <str>} = val
T{*, <cell>} = val
horzcat(varargin)

Concatenate tables horizontally.

T = [T1 T2]
vertcat(varargin)

Concatenate tables vertically.

T = [T1; T2]
display()

Display the table contents.

This method is called automatically when omitting a semicolon on a line that retuns an object of this class.

By default it displays only the first and last 10 rows if there are more than 25 rows.

Does not currently display the contents of any nested tables.

static extract_named_args(args)

Extracts special named constructor arguments.

[var_names, row_names, dim_names, args] = extract_named_args(var1, var2, ...)
[...] = extract_named_args(..., 'VariableNames', {name1, name2, ...})
[...] = extract_named_args(..., 'RowNames', {name1, name2, ...})
[...] = extract_named_args(..., 'DimensionNames', {name1, name2, ...})

Used to extract named arguments, 'VariableNames', 'RowNames', and 'DimensionNames', to pass to constructor.