Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

na_0021: Strings

ID: Title

na_0021: Strings

Priority

Strongly recommended

Scope

NA-MAAB

MATLAB Versions

All

Prerequisites

None

Description

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. 

Note

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

Rationale

  • Verification and Validation

  • Workflow

  • Code Generation

See Also

  • NASA Orion style guideline jh_0024: Strings

Last Changed

V3.0

Introduced in R2013a

Was this topic helpful?