Main Content

Data Input

Generate data input field on device screen

Add-On Required: This feature requires the Simulink Support Package for Android Devices add-on.

  • Data Input block

Libraries:
Simulink Support Package for Android Devices / User Interface

Description

The Data Input block generates a data input field on the Android™ device screen. The data input field is an edit box to enter or modify data by typing on the device keyboard. The Data Type parameter in the Block Parameters dialog box specifies the type of data that can be entered in the data input field.

The block outputs the value that you enter in the data input field. For a character vector input, the block outputs the corresponding ASCII values.

Note

During simulation without hardware, this block outputs zeros. For more information, see Block Produces Zeros or Does Nothing in Simulation.

Ports

Output

expand all

The block outputs the value that you enter in the data input field by typing on the device keyboard.

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

Parameters

expand all

Select this option to enable entry of character vector data in the data input field.

  • When you select the Character vector input option, the layout of the keyboard on your Android device changes to QWERTY. The data input field accepts any value supported by the QWERTY keyboard.

    The block outputs a 1-by-N vector with uint8 values that corresponds to the ASCII values of the characters entered in the data input field. N is the length specified in the Number of characters parameter.

  • When you clear the Character vector input option, the layout of the keyboard remains numeric. The data input field accepts only those values that are aligned to the type specified in the Data type parameter.

    When Input Is a Character VectorWhen Input Is Numeric

  • For numeric input, the block converts the initial value to the type specified in the Data type parameter, and then displays it on the data input field. For example, if Initial value is specified as 1 and the Data type parameter is set to double, the value displayed in the data input field is 1.0000000000000.

  • For character vector input, ensure that the length of the character vector in the Initial value parameter does not exceed the value specified in the Number of characters parameter.

Specify the maximum number of characters that can be entered in the data input field. The data input field does not accept any input beyond the length specified in the Number of characters parameter.

If the number of characters in the character vector is less than the length specified in the Number of characters parameter, the block fills the empty spaces in the output array with zeros.

This table shows the block output when the length of the character vector entered in the data input field is less than, equal to, or greater than the length specified in the Number of characters parameter, using the text Hello as an example.

Length of Data in Data Input Field < Number of Characters Length of Data in Data Input Field = Number of Characters Length of Data in Data Input Field > Number of Characters
Number of Characters = 8Number of Characters = 5Number of Characters = 2

Dependencies

The Number of characters parameter appears when you select the Character vector input option.

Specify the type of the data entered in data input field. The data input field accepts input only within the range specified in the Data type parameter. For example, if you set Data type to int8, the data input field does not accept any value beyond the range of −128 to 127.

Note

You may observe that the floating-point computation of a single or a double data entered in the data input field is not as precise as you had expected. Conforming to the IEEE standard 754, Simulink® represent numbers to finite precision. For more information on computation of floating-point data, see Floating-Point Numbers.

Dependencies

The Data type parameter appears when you clear the Character vector input option.

Specify how often the block reads data from the data input field, measured in seconds. When you specify this parameter as -1, Simulink determines the best sample time for the block based on the block context within the model.

Version History

Introduced in R2018a