stringtype - Create string data type - MATLAB (original) (raw)
Main Content
Syntax
Description
[string](#d126e568640) = stringtype([maximum_length](#d126e568602))
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](#d126e568602))
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, orCompose String block.
Tip
Specifying stringtype(0)
creates a string data type with no maximum length. This syntax is the same as specifyingstring
for Simulink block data types.
Examples
Create a string data type of maximum length 10.
h =
StringType with properties:
MaximumLength: 10
Description: ''
DataScope: 'Auto'
HeaderFile: ''
Create a string data type that uses symbolic expression for maximum length. For more information about symbolic dimensions, see Implement Symbolic Dimensions for Array Sizes in Generated Code (Simulink Coder).
A = Simulink.Parameter(int32(10)); A.Min = 1; A.Max = 100; A.StorageClass = 'Define'; A.CoderInfo.CustomAttributes.HeaderFile = 'symbols.h'; h = stringtype("A")
h =
StringType with properties:
MaximumLength: 'A'
Description: ''
DataScope: 'Auto'
HeaderFile: ''
Input Arguments
When the maximum length of the string data type is specified as a scalar, it can take values from 1 to 32766. This value can be an integer, MATLAB variable, or MATLAB expression.
You can also use symbolic expressions for maximum length. (since R2024a)
Data Types: double
| string
Output Arguments
String object, specified as a scalar.
Version History
Introduced in R2018a
You can use symbolic expressions to specify for maximum length for string data types that you create.
This enhancement allows you to update the maximum length by updating the symbolic expression value. Thus, you can avoid rebuilding the model each time you update the maximum length.