Main Content

readMobileSensorData

Import collected data file from mobile device via USB connection

Description

Add-On Required

To use this function for accessing mobile device sensors remotely from MATLAB® installed on a desktop or laptop computer, you must also install either MATLAB Support Package for Apple iOS Sensors or MATLAB Support Package for Android® Sensors. For more information, see Get and Manage Add-Ons.

s = readMobileSensorData('filename') reads the file, filename, extracts the sensor data from it, and creates a structure, s, where each field in the structure is a timetable with the sensor data. The file contains sensor data collected by MATLAB Mobile locally on a mobile device.

This function is required only when you manually transfer a sensor log file from a mobile device to your computer using a USB cable. If you upload the sensor file from the mobile device to MATLAB Drive, you do not need to use this function.

example

Examples

collapse all

Use of this function is the last step in a workflow in which you log sensor data locally on your mobile device using the Sensors menu in MATLAB Mobile, and then transfer the log file manually to your computer using a USB cable. The function then imports the sensor data into MATLAB. These steps are outlined in Sensor Data Collection with MATLAB Mobile.

Import a sensor log that you previously created on MATLAB Mobile, and manually transfer it to your computer.

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 example, create a variable for the acceleration data.

acceleration = s.Acceleration;

Plot the acceleration data.

plot(acceleration.Timestamp, acceleration{:, 2:end})

Input Arguments

collapse all

Name of sensor data file, specified as a string. This file is created when you log sensor data locally using the Sensors tab in MATLAB Mobile on your mobile device. The default file name is sensorlog followed by the date and timestamp, as shown in the example here. You can change the file name when you log the data in MATLAB Mobile.

Example: s = readMobileSensorData('sensorlog_20180616_102034.zip')

Data Types: char | string

Output Arguments

collapse all

Sensor data collected on MATLAB Mobile, returned as a structure. The readMobileSensorData function extracts the sensor data from the file and creates the structure, in which each field is a timetable with the sensor data collected by MATLAB Mobile locally on a mobile device.

The structure contains one or more of the following fields. If you collected data from only one sensor, it contains data from only that sensor.

  • Acceleration - timetable with acceleration data

  • AngularVelocity - timetable with angular velocity data

  • MagneticField - timetable with magnetic field data

  • Orientation - timetable with orientation data

  • Position - timetable with position data

Version History

Introduced in R2018b