Main Content

String Compare

Compare two input strings

  • String Compare block

Libraries:
Simulink / String

Description

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.

Ports

Input

expand all

First string to compare, specified as a scalar.

Data Types: string

Second string to compare, specified as a scalar.

Data Types: string

Output

expand all

True or false result, specified as a scalar:

  • 1 — Match.

  • 0 — No match.

Data Types: Boolean

Parameters

expand all

Case sensitivity for string comparison:

on

Consider string case when comparing strings.

off

Do not consider string case when comparing strings.

Programmatic Use

Block Parameter: CaseSensitive
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Amount of string to compare:

  • Entire string — Compare both entire strings.

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

Dependencies

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

Programmatic Use

Block Parameter: CompareOption
Type: character vector
Values: 'Entire string' | 'First N characters'
Default: 'Entire string'

Number of characters to compare

Dependencies

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

Programmatic Use

Block Parameter: CompareOption
Type: character vector
Values: scalar
Default: '1'

Block Characteristics

Data Types

Boolean | string

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

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

Version History

Introduced in R2018a