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.

String Compare

Compare two input strings

  • Library:
  • Simulink / String


String Compare compares two strings. To see if two strings are identical, use this block. You can specify if the match is case sensitive and how much of the string to compare.



expand all

First string to compare, specified as a scalar.

Data Types: string

Second string to compare, specified as a scalar.

Data Types: string


expand all

True or false result, specified as a scalar:

  • 1 — Match.

  • 0 — No match.

Data Types: Boolean


expand all

Case sensitivity for string comparison:


Consider string case when comparing strings.


Do not consider string case when comparing strings.

Amount of string to compare:

  • Entire string — Compare both entire strings.

  • First N characters — Compare the first N characters of both strings.


Setting this parameter to First N characters enables the Number of characters parameter.

Number of characters to compare


This parameter is enabled when the Compare Option parameter is set to First N characters.

Data Types: double

Block Characteristics

Data Types

Boolean | 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