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.

Get Started with Android Sensors

Requirements for Using MATLAB Support Package for Android Sensors

The MATLAB® Support Package for Android™ Sensors enables you to collect sensor data from your mobile Android device, such as a phone or tablet, and log it in MATLAB. You can then process the sensor data in MATLAB in a variety of ways, including creating plots. You can collect data from the following sensors:

  • Acceleration

  • Angular Velocity

  • Orientation

  • Magnetic Field

  • Position

The Android Sensors support package requires the following:

  • Installation of MATLAB Mobile™ on your Android device. You can get this application from the Google Play™ store.

  • MATLAB version R2014a or later, for creating the connection to the application and logging sensor data.

  • Installation of the MATLAB Support Package for Android Sensors on your computer, or a MathWorks Cloud account. The support package is already installed in the MathWorks Cloud.

The support package includes the command-line interface in MATLAB and the ability to interact with the Android Sensors in MATLAB Mobile. You create a mobiledev object in MATLAB to connect to the sensors on the device, and then collect the data. You can make the connection between your computer running MATLAB and the device via either Wi-Fi or your cellular network, or use MATLAB on the MathWorks Cloud.

Note

Please note that MATLAB Mobile and MATLAB Connector™ are intended for use behind a firewall on a private network. If you plan to use MATLAB Mobile and MATLAB Connector over the public Internet, via 3G, or via 4G, it is recommended you use a Virtual Private Network (VPN).

Get Started

Follow these steps to get started sending sensor data using the MATLAB Support Package for Android Sensors.

  1. Install the support package in MATLAB if you will be running the MATLAB session on a computer.

  2. Install MATLAB Mobile on your Android device. You can get this application from the Google Play Store.

  3. Using MATLAB Connector, connect your Android device to the computer running MATLAB, via Wi-Fi or your cellular network. Alternatively, you can use the MathWorks Cloud. For details, see Set Up and Connect to Android Device.

    Note

    Please note that MATLAB Mobile and MATLAB Connector are intended for use behind a firewall on a private network. If you plan to use MATLAB Mobile and MATLAB Connector over the public Internet, via 3G, or via 4G, it is recommended you use a Virtual Private Network (VPN).

  4. Review the sensor settings on the device, on the Settings screen of MATLAB Mobile. To access them, tap the Menu button, then Settings, and then scroll to the Sensors section.

    Control from MATLAB — this is on by default and needs to remain on in order to control the sensors and logging of data from MATLAB.

    Send Data in Background — this is off by default, but turn it on if you want to continue to send sensor data when the application goes into the background on the device.

    Getting Started with Sensors — use to access the Getting Started information.

  5. In MATLAB, create a mobiledev object to access the sensor data.

    m = mobiledev

    For more details, see Acquire Sensor Data Streaming.

  6. You can then control the sensors, log the sensor data, query latest values, and plot the data or do other post-processing tasks. For details on these actions, see Acquire Sensor Data Streaming, Use Properties to Control Android Sensor Acquisition, and Use Logged Sensor Data.