Convert string arrays at any level of cell array or structure
To make your code accept cell arrays and structures that contain strings as input
arguments, add a call to convertContainedStringsToChars
to the beginning
of your code. Then you do not have to make any other changes to code that you had written to
work with cell arrays or structures containing character arrays.
B = convertContainedStringsToChars(
converts
string arrays at any level in A
)A
.
If A
is a string array, then B
is a character
vector or cell array of character vectors.
If A
is a cell array or a structure, then string arrays in any
cell or field of A
become character vectors or cell arrays of
character vectors in B
. All other cells or fields of
A
are unaltered in B
.
Otherwise, the function returns A
unaltered.
[B1,...,Bn] = convertContainedStringsToChars(A1,...,An)
converts
the input arguments A1,...,An
. For every input argument, there must be a
corresponding output argument in B1,...,Bn
.
convertCharsToStrings
| convertStringsToChars
| ischar
| isstring
| isStringScalar
| string
| validateattributes