Function found = fieldcheck(x,keys);
returns true if the field path indicated
by special cell array keys exists
in matrix, cell array or struct x.
Cell array keys is a row cell array of
which the elements contain:
-- a string, to indicate a field in
a struct;
-- a row cell array, of which the
elements contain:
-- an integer, or a matrix of
integers, to indicate one or
more indices in a certain
dimension;
-- string ":", to indicate all
elements in a certain dimension;
-- string "()", for an index of a
matrix, or ()-indexing of a
cell array. Without "()",
{}-indexing is assumed.
Each element in the row cell
array, except for "()", relates
to a dimension of the matrix or
cell array.
Note the usual behaviour of Octave:
-- {}-indexing on a cell array returns
the contents of the indicated
elements;
-- ()-indexing on a cell array returns
the indicated elements wrapped
into a cell array;
-- ()-indexing is the only way for
indexing on a matrix.
E.g. applying
keys = {"a","b",{2},"c"}
onto struct x where x.a.b contains
a cell array, and x.a.b{2} contains
a struct with field "c", is equivalent
to directly writing:
x.a.b{2}.c
E.g. applying
keys = {"a",{2,3},{"()",":",4}}
onto struct x where where x.a contains
a two-dimensional cell array and its
element {2,3} contains a two-dimensional
matrix or cell array, is equivalent
to directly writing:
x.a{2,3}(:,4)
(c) 2026 fabien van mook
2026.08.20 release of this file within package "fvm-record" under GNU GPLv3+