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.

Collect Sensor Data

Stream Sensor Data to MATLAB

Send sensor data to MATLAB® running on MathWorks® Cloud or on a computer.

  1. If you are sending to a computer, make sure MATLAB Support Package for Android™ Sensors is installed.

  2. From MATLAB Mobile™, connect to the target computer or MathWorks Cloud running MATLAB.

  3. On MATLAB Mobile, create a mobiledev object in MATLAB; for example:

     >> m = mobiledev 
  4. Tap and then tap Sensors.

  5. Tap the icon for the sensor you want to turn on.

  6. If not already selected, tap Stream to MATLAB.

  7. To start sending data to MATLAB, tap START.

  8. To stop sending data, tap STOP.

Repeat these steps to collect more data.

Log Sensor Data Locally

Capture sensor data locally to a file on your device.

Step 1. Collect Sensor Data

  1. In Sensors, turn on the sensors for collecting data.

  2. Select Log.

  3. To start collecting data, tap START.

  4. To stop collecting data, tap STOP.

  5. When prompted, Enter log name, or you can accept the default.

Repeat these steps to collect and save more data.

Step 2. Manually Transfer Sensor Logs

Transfer sensor logs to MATLAB.

If you have Auto Upload enabled, you do not need to manually transfer sensor logs, as the logs are uploaded automatically when you have a WiFi or cellular (if selected) connection.

However, if Auto Upload is off, or if you want to re-send a sensor log, you can manually upload the file to MATLAB via MATLAB Drive™ or to a computer running MATLAB via USB cable.

  • To MATLAB via MATLAB Drive:

    1. Tap the file icon on the Sensors screen.

    2. In the files list, tap the menu on the file you want to transfer and then tap Upload.

      Logs are uploaded as MAT files to the default folder MATLAB Drive/MobileSensorData. You can change the destination folder in Settings. Sensor logs show automatically in your MATLAB Drive after a successful upload.

    3. On desktop MATLAB, move the transferred sensor files from MATLAB Drive to the MATLAB working directory.

  • To MATLAB via USB Cable:

    These instructions apply to MATLAB 2017a and later only.

    1. Connect your mobile device to the computer using a USB cable.

    2. Transfer sensor files from the mobile device to the MATLAB working directory or to any writable folder. How to do this varies by device manufacturer; consult your mobile device guide for assistance.

    3. Import sensor data into MATLAB.

      1. Make sure the MATLAB Support Package for Android Sensors is installed on the target computer.

      2. Import the sensor data into MATLAB using the readMobileSensorData function (found in the MATLAB Support Package for Android Sensors):

        s = readMobileSensorData(filename)

Delete Log Files

To delete sensor logs from your mobile device:

  1. Tap the file icon on the Sensors screen.

  2. In the files list, tap the menu on the file you want to remove and then tap Delete.

    This action deletes the sensor log from the device. Sensor logs uploaded to MATLAB Drive are not deleted with this action; you must go to your MATLAB Drive to delete them.

Related Topics