Sensor Data Collection

Collect sensor data from your device

With MATLAB® Mobile™, you can collect sensor data from your iOS device and log the data in MATLAB. Use MATLAB to process this data in various ways, including creating plots.

You can collect data from these sensors:

  • Acceleration

  • Angular velocity

  • Magnetic field

  • Orientation

  • Position

In order to collect sensor data, you need to connect to the MathWorks Cloud and create a mobiledev object in MATLAB Mobile. For information, see Get Started with iOS Sensors and Set Up and Connect to Apple iOS Device. Then, you need to turn on the sensors and log data to MATLAB. You can process the logged data, including creating plots. For an example of acquiring data and plotting it, see Use Logged Sensor Data.

You can also acquire sensor data locally on the iOS device, with or without a network connection. This is an alternative method of collecting the sensor data instead of streaming it from the device to your computer running MATLAB. This is especially useful if you want to collect sensor data while your device does not have a network connection. For examples of using this method of acquisition, see Acquire Sensor Data Locally on Mobile Device.

You can also access the camera and acquire images on your iOS mobile device from MATLAB Mobile. Set camera properties including resolution, autofocus, and flash. For an example, see Acquire Images from iOS Camera. Then, process the acquired images. For an example, see Classify Images from iOS Camera Using Pretrained Network.

Functions

mobiledevCreate mobiledev object to acquire data from iOS sensors
dispDisplay properties of mobiledev object
accellogReturn logged acceleration data from iOS sensor
angvellogReturn logged angular velocity data from iOS sensor
magfieldlogReturn logged magnetic field data from iOS sensor
orientlogReturn logged orientation data from iOS sensor
poslogReturn logged position data from iOS sensor
discardlogsDiscard all logged data from iOS sensors
readMobileSensorDataImport sensor data from file collected by MATLAB Mobile
cameraConnection to camera on iOS device
snapshotAcquire single image frame from iOS device camera

Topics

Setup and Configuration

Set Up Sensors

Review requirements for sensor collection with MATLAB Mobile; how to manage sensor settings

Collect Sensor Data

Start and stop sensor data collection; transfer and load files into MATLAB

Get Started with iOS Sensors

Follow these steps to get started sending sensor data.

Set Up and Connect to Apple iOS Device

You can use MATLAB on a computer or on the MathWorks Cloud. The following sections outline the connection procedure for each scenario.

Apple iOS Sensors Data Acquisition

Acquire Sensor Data Streaming

You communicate with the iOS device by creating a mobiledev object. You can then control the sensors and acquire data from them.

Use Properties to Control iOS Sensor Acquisition

You can use properties to display current sensor values, enable and disable sensors from MATLAB, turn logging on and off, set sample rate, and show connection and logging status.

Use Logged Sensor Data

You can use the logged sensor data either during or after acquisition for plotting and other analyses. This example shows how to plot orientation data.

Acquire Sensor Data Locally on Mobile Device

You can acquire sensor data locally on the iOS device, with or without a network connection.

Apple iOS Camera Image Acquisition

Acquire Images from iOS Camera

This example shows how to connect to your iOS mobile device camera and acquire images from it.

Classify Images from iOS Camera Using Pretrained Network

This example shows how to use deep learning to classify images acquired by your iOS mobile device camera.

Featured Examples