Code generation supports 1-by-1 MATLAB® string arrays. Code generation does not support string arrays that have more than one element.
A 1-by-1 string array, called a string scalar, contains one
piece of text, represented as a 1-by-n character vector. An example of a string scalar
"Hello, world". For more information about strings, see Text in String and Character Arrays (MATLAB).
For string scalars, code generation does not support:
Indexing with curly braces
Defining input types programmatically (by using preconditioning with
Their use with
For code generation, limitations that apply to classes apply to strings. See MATLAB Classes Definition for Code Generation.
Converting a string that contains multiple unary operators to
double can produce different results between
MATLAB and the generated code. Consider this
function out = foo(op) out = double(op + 1); end
For an input value
"--", the function converts the
double. In MATLAB, the answer is
NaN. In the generated code,
the answer is
Double conversion for a string with misplaced commas (commas that are not used as thousands separators) can produce different results from MATLAB.