Main Content

String Constant

Output specified string

  • String Constant block

Simulink / String


The String Constant block outputs a string specified by the String parameter. Use this block when you want a constant whose type is string.


The Output data type parameter does not support string data types that use symbolic expressions to specify the maximum length because signals with symbolic dimensions must be driven by a block with nonconstant sample time. For example, the Output data type parameter specified as stringtype("N") with N defined as a symbolic expression is not supported.



expand all

Output string, specified as a scalar.

Data Types: string


expand all

Input string, specified as a scalar.

Programmatic Use

Block Parameter: String
Type: character vector
Values: '"Hello!"' | scalar
Default: '"Hello!"'

Output data type, specified using the string data type to specify a string with no maximum length.

To specify a string data type with a maximum length, specify stringtype(N). For example, stringtype(31) creates a string data type with a maximum length of 31 characters.

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the data type attributes. See Specify Data Types Using Data Type Assistant for more information.

Programmatic Use

Block Parameter: OutDataTypeStr
Type: character vector
Values: 'string' | <data type expression>
Default: 'string'

Use the stringtype function, for example, stringtype(31).


Clicking the Show data type assistant button enables this parameter.

Block Characteristics

Data Types


Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2018a