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 Apple iOS 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 the current menu selection 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. If you are using the position sensor, turn on Location Services for MATLAB.

    1. In the Settings app on your mobile device, tap Privacy and tap Location Services.

    2. Tap MATLAB and tap While Using the App.

  9. 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. Tap the current menu selection and then tap Sensors.

  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, swipe left on the file you want to transfer and select 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 tranferred 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. If you do not know how, see the following article: Share Files between computer and iPhone, iPad, or iPod touch.

    3. Import sensor data into MATLAB.

      1. Make sure the MATLAB Support Package for Apple iOS 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 Apple iOS 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, swipe left on the file you want to transfer and select 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