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.


Extract substring from input string signal

  • Library:
  • Simulink / String


The Substring block extracts a substring from the input string signal. The block extracts the substring starting from the letter corresponding to idx and includes a len number of characters starting at idx. For example, if the input string is "hello 123", input idx is 1, and input len is 5, the output is "hello". The block extracts a substring starting at 1 and the next 4 characters for a total of 5 characters (hello).



expand all

Input string signal, specified as a string.

Data Types: string

Start of string to extract, specified as a positive scalar integer.

Data Types: int8 | int16 | int32 | uint8 | uint16 | uint32

Length of string to extract, specified as a scalar. If len causes the substring to extend beyond the end of the string, the output signal contains few than len characters.

Data Types: uint8 | uint16 | uint32


expand all

Extracted string, specified as a scalar.

Data Types: string


expand all

Use same maximum length as the input string source block.


Use same maximum length. The substring includes the characters starting from the character at idx to the end of the string.


Do not use same maximum length.

Extract string from idx to end of input string.


Extract string from idx to end of input string.


Do not extract string from idx to end of input string.


Selecting this parameter removes the third input port.

Block Characteristics

Data Types

integer | string

Direct Feedthrough


Multidimensional Signals


Variable-Size Signals


Zero-Crossing Detection


Extended Capabilities

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

Introduced in R2018a