Data Input
Generate data input field on device screen
Add-On Required: This feature requires the Simulink Support Package for Android Devices add-on.
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.
Examples
Accept Input from Android Keyboard
Accept input values from the Android® keyboard and convert them to a logical output using Simulink® Support Package for Android Devices.
Ports
Output
Port_1 — Value entered in data input field
1.0
(default) | vector
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
Character vector input — Option to specify if the input data is a character vector data
off (default)
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 Vector When Input Is Numeric
Initial value — Default value of data input field
0.1
(default) | any valid value of the current data type
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 todouble
, the value displayed in the data input field is1.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.
Number of characters — Maximum length of character vector
100
(default) | any positive integer less than 256
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 =
8 | Number of Characters =
5 | Number of Characters =
2 |
|
|
|
Dependencies
The Number of characters parameter appears when you select the Character vector input option.
Data type — Data type of entered data
double
(default) | uint8
| int8
| uint16
| int16
| uint32
| int32
| single
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.
Sample time — How often the block reads data
0.1
(default) | -1
| any positive integer
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
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)