Main Content

mobiledev

Create mobiledev object to acquire data from Android sensors

Description

example

m = mobiledev creates an object m that reads sensor data from an Android™ device running MATLAB® Mobile™ that is connected to the same network as a computer running MATLAB. The object can read data from five types of sensors: acceleration, angular velocity, orientation, magnetic field, and position. Use this syntax 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.

Examples

collapse all

This example assumes that you have already installed and set up MATLAB Mobile on your Android device and connected it to your computer running MATLAB. For information about these steps, see Sensor Data Collection with MATLAB.

Start MATLAB Mobile on your Android device.

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

Place the device where you want to get the sensor data, if a remote location.

In MATLAB on your computer, create a mobiledev object, m.

m = mobiledev
mobiledev with properties:

                   Connected: 1
                     Logging: 0
            InitialTimestamp: ''

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

Supported functions

In the display that is shown when you create the object, a value of 1 means enabled or on, and 0 means not enabled or off. The device and computer are connected, but data is not being sent (logged) yet.

To begin logging data, enable the Logging property.

m.Logging = 1

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

When you have more than one device set up for sensor data, you 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('Pixel 3')
mobiledev with properties:

                      Device: 'Pixel 3'
                   Connected: 1
                     Logging: 0
            InitialTimestamp: ''

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

Supported functions

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

Version History

Introduced in R2014b