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.

Acquire Sensor Data Locally on Mobile Device

You can acquire sensor data locally on an iOS device, with or without a network connection. You can use this alternative method for collecting sensor data instead of streaming it from the device to your computer running MATLAB or to the MathWorks Cloud. This is especially useful if you want to collect sensor data while your device does not have a network connection.

Acquire Sensor Data on Device with No Network Connection

This example shows how to log sensor data locally on your mobile device when you have no network connection and upload the files to MATLAB Drive once you are connected. You must log into your MathWorks Account to use MATLAB Drive. If you are not logged in, you are prompted to do so.

Note

This example assumes that you have already installed and set up MATLAB® Mobile™ on your Apple iOS device. For information about these steps, see Set Up and Connect to Apple iOS Device.

  1. Start MATLAB Mobile on your iOS device.

  2. In Settings, go to Sensors > Configure > MATLAB Drive Upload, and change the Auto Upload setting to Off.

  3. On the Sensors screen of MATLAB Mobile, tap the sensors that you want to collect data from.

  4. To log the data locally on the device, select Log.

  5. To begin collecting sensor data, tap the Start button.

  6. When you are done collecting sensor data, tap the Stop button.

  7. In the pop-up, accept the default name for the log file, or change the name, and tap Save.

    The default file name is sensorlog followed by the date and timestamp, for example, sensorlog_20180616_102034. In this example, the first four digits are the year, followed by two digits for the month and two digits for the day, which is June 16, 2018. The digits after the underscore are the time in hours, minutes, and seconds, which is 10:20 and 34 seconds in this example.

    The log is saved, and a visual indicator of the log appears on the sensor log button on the lower right of the screen. A red number on the icon indicates how many logs you have saved. The number increments as you collect and save more logs.

  8. When you have network connection again on your device, you can upload the log files to MATLAB Drive. Go to the Sensor Logs screen by tapping the sensor log button at the bottom of the Sensors screen.

    The logs you have captured are listed there, with the most recent log listed first.

  9. In the log list, select the log to upload, and swipe to select Upload.

    While the file is uploading, a progress indicator spins next to the log name. When the upload is completed, a Cloud icon confirms it was successfully uploaded to MATLAB Drive.

  10. Logs are uploaded as MAT-files to the default folder location, which is

    \MATLAB Drive\MobileSensorData\

    You can optionally change the default folder location in Settings > Sensors > Configure > Upload Folder.

  11. Once logs are uploaded, you can access them in MATLAB Online, or any product that connects to MATLAB Drive.

    In MATLAB Online, go to the default folder, and use the load command to see the sensor data.

    load('sensorlog_20180616_102034.mat')

Acquire Sensor Data on Device and Auto-Upload Logs

This example shows how to log sensor data locally on your mobile device when you have a network connection, and upload the files to MATLAB Drive using the auto upload feature. You must log into your MathWorks Account to use MATLAB Drive. If you are not logged in, you are prompted to do so.

Note

This example assumes that you have already installed and set up MATLAB Mobile on your Apple iOS device. For information about these steps, see Set Up and Connect to Apple iOS Device.

  1. Start MATLAB Mobile on your iOS device.

  2. Make sure auto upload is turned on. The setting is turned on by default. In Settings, go to Sensors > Configure > MATLAB Drive Upload, and change the Auto Upload setting to On if it is turned off.

  3. On the Sensors screen of MATLAB Mobile, tap the sensors that you want to collect data from.

  4. To log the data locally on the device, select Log.

  5. To begin collecting sensor data, tap the Start button.

  6. When you are done collecting sensor data, tap the Stop button.

  7. In the pop-up, accept the default name for the log file, or change the name, and tap Save.

    The default file name is sensorlog followed by the date and timestamp, for example, sensorlog_20180616_102034. In this example, the first four digits are the year, followed by two digits for the month and two digits for the day, which is June 16, 2018. The digits after the underscore are the time in hours, minutes, and seconds, which is 10:20 and 34 seconds in this example.

    The log is saved, and a visual indicator of the log appears on the sensor log button on the lower right of the screen. A red number on the icon indicates how many logs you have saved. The number increments as you collect and save more logs.

  8. If you have network connection on your device, and auto upload is turned on in Settings, the log files are automatically uploaded to MATLAB Drive. Go to the Sensor Logs screen by tapping the sensor log button at the bottom of the Sensors screen.

  9. The logs you have captured are listed there, with the most recent log listed first.

    While the file is uploading, a progress indicator spins next to the log name. When the upload is completed, a Cloud icon confirms it was successfully uploaded to MATLAB Drive.

  10. Logs are uploaded as MAT-files to the default folder location, which is

    \MATLAB Drive\MobileSensorData\

    You can optionally change the default folder location in Settings > Sensors > Configure > Upload Folder.

  11. Once logs are uploaded, you can access them in MATLAB Online, or any product that connects to MATLAB Drive.

    In MATLAB Online, go to the default folder, and use the load command to see the sensor data.

    load('sensorlog_20180616_102034.mat')

Acquire Sensor Data on Device and Transfer Logs Manually

This example shows how to log sensor data locally on your mobile device, and then manually copy the logs to your computer running MATLAB.

Note

This example assumes that you have already installed and set up MATLAB Mobile on your Apple iOS device. For information about these steps, see Set Up and Connect to Apple iOS Device.

  1. Start MATLAB Mobile on your iOS device.

  2. In Settings, go to Sensors > Configure > MATLAB Drive Upload, and change the Auto Upload setting to Off.

  3. On the Sensors screen of MATLAB Mobile, tap the sensors that you want to collect data from.

  4. To log the data locally on the device, select Log.

  5. To begin collecting sensor data, tap the Start button.

  6. When you are done collecting sensor data, tap the Stop button.

  7. In the pop-up, accept the default name for the log file, or change the name, and tap Save.

    The default file name is sensorlog followed by the date and timestamp, for example, sensorlog_20180616_102034. In this example, the first four digits are the year, followed by two digits for the month and two digits for the day, which is June 16, 2018. The digits after the underscore are the time in hours, minutes, and seconds, which is 10:20 and 34 seconds in this example.

    The log is saved, and a visual indicator of the log appears on the sensor log button on the lower right of the screen. A red number on the icon indicates how many logs you have saved. The number increments as you collect and save more logs.

  8. You can see the saved logs on the Sensor Logs screen by tapping the sensor log button at the bottom of the Sensors screen.

    The logs you have captured are listed there, with the most recent log listed first.

  9. Transfer the logs from your mobile device to the computer running MATLAB using a USB cable.

  10. Navigate to the folder containing the zip file, then import a sensor log into MATLAB using the readMobileSensorData function.

    s = readMobileSensorData('sensorlog_20180726_102034.zip')

    The structure, s, is created and contains sensor data from up to five supported sensor types. You can then access data from any of the sensors. For an example, see readMobileSensorData.