Main Content

mobiledev

Create mobiledev object to acquire data from mobile device sensors

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.

m = mobiledev creates a mobiledev object m that reads sensor data from any device running MATLAB Mobile™ with the same MathWorks® account. The object can read data from any supported sensors: acceleration, angular velocity, orientation, magnetic field, position, microphone, and camera. Use this syntax without arguments when you have only one device set up for sensing. You cannot create more than one object for the same device.

example

m = mobiledev(devname) creates a mobiledev object to read data from the device identified by devname. Use this syntax when you have more than one device connected to your MathWorks account. You can create several mobiledev objects, each one for a different device, up to the supported limit. For a list of possible devices, use mobiledevlist.

example

Examples

collapse all

This example assumes that you have already installed and set up MATLAB Mobile on your device, running with the same MathWorks account. If you have not, see Install MATLAB Mobile on Your Device.

Start MATLAB Mobile on your mobile device.

On the Sensors screen, tap the sensors that you want to send data from.

Place the device where you want to get the sensor data.

In MATLAB create a mobiledev object, m.

m = mobiledev
mobiledev with properties:

                      Device: 'iPhone - iPhone 11 Pro Max'
                   Connected: 1
                     Logging: 0
            InitialTimestamp: ''

   AccelerationSensorEnabled: 1
AngularVelocitySensorEnabled: 1
  MagneticFieldSensorEnabled: 1
    OrientationSensorEnabled: 1
       PositionSensorEnabled: 1

In the display that is shown when you create the object, a value of 1 indicates enabled, and 0 indicates disabled. The device and MATLAB are connected, but data is not being exchanged yet.

To begin logging data, enable the Logging property.

m.Logging = 1

This action starts the transmission of data from all selected sensors.

When you have more than one device set up for sensor data, you can specify which device to use for data transmission. Set up the devices as described in the previous example.

Identify your devices in MATLAB.

mobiledevlist
ans =  

 2×2 table
 
 Device  Status  
 ______________________________  ____________________
 
 {'Pixel 3'}                    {'Ready To Connect'}
 {'iPhone - iPhone 11 Pro Max'} {'Ready To Connect'}

Create a mobiledev object for a specific device.

m = mobiledev('iPhone - iPhone 11 Pro Max')
mobiledev with properties:

                      Device: 'iPhone - iPhone 11 Pro Max'
                   Connected: 1
                     Logging: 0
            InitialTimestamp: ''

   AccelerationSensorEnabled: 1
AngularVelocitySensorEnabled: 1
  MagneticFieldSensorEnabled: 1
    OrientationSensorEnabled: 1
       PositionSensorEnabled: 1

From here you access data in the same manner as in the previous example.

Input Arguments

collapse all

Device name, specified as a string or character vector. This value is determined by the device settings. You can access the list of possible devices and their names with the mobiledevlist function.

Example: "Pixel 3"

Data Types: char | string

Version History

Introduced in R2015a