Main Content


Create string data type



string = stringtype(maximum_length) creates a Simulink® string data type with a maximum length. Alternatively, you can also create string data types using the String Constant, String Concatenate, and Compose String blocks.

stringtype(maximum_length) creates a Simulink string data type with a maximum length that you can type directly on the MATLAB® command line or in the Output data type parameter of the String Constant, String Concatenate, or Compose String block.


Specifying stringtype(0) creates a string data type with no maximum length. This syntax is the same as specifying string for Simulink block data types.


collapse all

Create a string data type of maximum length 10.

h = 

  StringType with properties:

    MaximumLength: 10
      Description: ''
        DataScope: 'Auto'
       HeaderFile: ''

Input Arguments

collapse all

Maximum length of string data type, specified as a scalar, from 1 to 32766. This value can be an integer, MATLAB variable, or MATLAB expression.

Data Types: double

Output Arguments

collapse all

String object, specified as a scalar.

Version History

Introduced in R2018a