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.

Scan String

Scan input string and convert to signals per specified format

  • Library:
  • Simulink / String

Description

The Scan String block scans an input string and converts it to signals per the format specified by the Format parameter. The block converts values to their decimal (base 10) representation and outputs the results as numeric or string signals. Use this block when you want to deconstruct a string, for example a sentence, into its individual components. For example, if the Format parameter is set to "%s is %f.", the block outputs two parts, a string signal and a single signal. If the input is the string "Pi is 3.14", the two outputs are "Pi" and "3.14".

Note

If you specify a numeric display format that is not large enough to display all the digits of a value, the displayed values may lose precision. The result depends on your computer hardware and operating system.

The Scan String, String to Double, and String to Single blocks are identical blocks. When configured for String to Double, the block converts the input string signal to a double numerical output. When configured for String to Single, the block converts the input string signal to a single numerical output.

For code generation, configure models that contain this block for non-finite number support by selecting the Configuration Parameters > Code Generation > Interface > Support non-finite numbers check box.

Ports

Input

expand all

Input string, specified as a scalar.

Data Types: string

Output

expand all

Output data whose format matches the specified format, defined as a scalar. Total maximum number of outputs is 128.

If the block cannot match an input string to a format operator specified in Format, it returns a warning and outputs an appropriate value (0 or "") for each unmatched format operator.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Output data whose format matches the %f format, specified as a scalar. Total maximum number of outputs is 128.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Output data whose format matches N format, specified as a scalar. Total maximum number of outputs is 128.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | enumerated | bus

Parameters

expand all

Format operator for input, specified as a scalar. If the block cannot match the input string with the specified format, it returns 0. The return of 0 differs from the sscanf function return, which is an empty matrix if the function cannot match the input with the specified format.

  • For the String to Double block, this parameter has a default value of %lf.

  • For the String to Single block, this parameter has a default value of %f.

For more information about acceptable format operators, see the Algorithms section.

Block Characteristics

Data Types

double | integer | single | string

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Algorithms

expand all

The Scan String block uses this format specifier prototype:

%[width][length]specifier

Extended Capabilities

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

Introduced in R2018a