This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

na_0021: Strings

ID: Title

na_0021: Strings


Strongly recommended



MATLAB Versions





The use of strings is not recommended. MATLAB® Functions store strings as character arrays. The arrays cannot be re-sized to accommodate a string value of different length, due to lack of dynamic memory allocation. Strings are not a supported data type in Simulink®, so MATLAB Function blocks cannot pass the string data outside the block.

For example, the following code will produce an error:

name='rate_error'; %this creates a 1 x 10 character array
name = 'x_rate_error'; %this causes an error because the array 
size is now 1 x 12, not 1 x 10. 


If the string is being used for switch / case behavior, consider using enumerated data types


  • Verification and Validation

  • Workflow

  • Code Generation

See Also

  • NASA Orion style guideline jh_0024: Strings

Last Changed


Model Advisor Check

By Task > Modeling Standards for MAAB > MATLAB Functions > Check usage of character vector inside MATLAB Function block

For check details, see Check usage of character vector inside MATLAB Function block.

Introduced in R2013a