Main Content

disp

Display properties of mobiledev object

Syntax

Description

example

disp(m) displays properties of m, the mobiledev object created to acquire sensor data from a mobile device. You can call the function any time during your mobiledev session, and the display indicates the state of the sensors.

Examples

collapse all

This example assumes that you have already installed and set up MATLAB® Mobile™ on your device. If you have not, see Install MATLAB Mobile on Your Device.

If you want to read the data in a different session of MATLAB, start MATLAB Online™ or MATLAB on your local computer. Using a local installation to read sensor data also requires one of the following support packages, appropriate for your mobile device:

  • MATLAB Support Package for Apple iOS Sensors

  • MATLAB Support Package for Android™ Sensors

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 your MATLAB session, 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

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 InitialTimestamp property is empty because no data has been logged yet. It represents the time when the first data point was transferred from the device to the mobiledev object.

Begin logging data from the selected sensors by enabling the Logging property.

m.Logging = 1

You can use disp at any time to see the status of the sensors and logging, and the current sensor values.

disp(m)
mobiledev with properties:

                   Connected: 1
                     Logging: 1
            InitialTimestamp: '06-08-2014 13:45:56.529'

   AccelerationSensorEnabled: 1   (1000 Logged values) 
AngularVelocitySensorEnabled: 1   (1200 Logged values) 
  MagneticFieldSensorEnabled: 1   (1005 Logged values) 
    OrientationSensorEnabled: 1   (1030 Logged values) 
       PositionSensorEnabled: 1   (800 Logged values) 

Current Sensor Values:
                Acceleration: [0.27 0.23 -10.19]  (m/s^2) 
             AngularVelocity: [-0.22 0.07 0.06]  (rad/s) 
               MagneticField: [3.56 1.56 -48.19]  (microtesla) 
                 Orientation: [85.91 -27.1 0.35]  (degrees) 

        Position Data:
                    Latitude: 41.29  (degrees) 
                   Longitude: -72.35  (degrees) 
                       Speed: 25.00  (m/s) 
                      Course: 83.60  (degrees) 
                    Altitude: 42.10  (m)
          HorizontalAccuracy: 9.00  (m) 

This display now shows that logging is enabled, and the initial timestamp is filled in, representing the timestamp when logging started. The sensor properties show the log size — how many values were logged when you called the disp function. If you call the function again in the same session, you see an increased number of logged values. The current sensor values show the values at the point of the display. In this way, you can use disp any time to check the values.

If any of the sensors are delayed in sending data, the display indicates that. For example, if the Position sensor has a lag, the position data values appear as follows:

disp(m)
mobiledev with properties:

                   Connected: 1
                     Logging: 1
            InitialTimestamp: '06-08-2014 13:45:56.529'

   AccelerationSensorEnabled: 1   (1000 Logged values) 
AngularVelocitySensorEnabled: 1   (1200 Logged values) 
  MagneticFieldSensorEnabled: 1   (1005 Logged values) 
    OrientationSensorEnabled: 1   (1030 Logged values) 
       PositionSensorEnabled: 1   (0 Logged values) 

Current Sensor Values:
                Acceleration: [0.27 0.23 -10.19]  (m/s^2) 
             AngularVelocity: [-0.22 0.07 0.06]  (rad/s) 
               MagneticField: [3.56 1.56 -48.19]  (microtesla) 
                 Orientation: [85.91 -27.1 0.35]  (degrees) 

        Position Data:
                    Latitude: [0x3 double] (Waiting for data) 
                   Longitude: [0x3 double] (Waiting for data) 
                       Speed: [0x3 double] (Waiting for data) 
                      Course: [0x3 double] (Waiting for data) 
                    Altitude: [0x3 double] (Waiting for data)
          HorizontalAccuracy: [0x3 double] (Waiting for data)

When the Position sensor starts sending data, subsequent uses of disp would show the values.

Stop logging data from the selected sensors by disabling the Logging property.

m.Logging = 0

This action stops the transmitting of data from all selected sensors. You can also stop transmission by tapping the Stop button in MATLAB Mobile.

When you stop logging data, the display shows the log size, but no current data.

disp(m)
mobiledev with properties:

                   Connected: 1
                     Logging: 0
            InitialTimestamp: '06-08-2014 13:45:56.529'

   AccelerationSensorEnabled: 1   (3000 Logged values) 
AngularVelocitySensorEnabled: 1   (3200 Logged values) 
  MagneticFieldSensorEnabled: 1   (3005 Logged values) 
    OrientationSensorEnabled: 1   (3030 Logged values) 
       PositionSensorEnabled: 1   (2400 Logged values) 

Notice that the Logging property changes back to disabled by showing a 0. The log sizes are the final number of values in the log session, for example, 3000 values from the Acceleration sensor. But the current values are no longer shown since you are no longer logging data.

Version History

Introduced in R2015a