This example assumes that you have already installed
and set up MATLAB®
Mobile™ on your iOS device and connected it to your computer
running MATLAB. If you have not, see Install MATLAB Mobile on Your Apple iOS Device.
Start MATLAB
Mobile on your iOS 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.
On your computer, create a mobiledev
object,
m
, in MATLAB.
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
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.
You can use disp
at any time to see the status
of the sensors and logging, and the current sensor values.
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)
Supported functions
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:
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)
Supported functions
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.
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.
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)
Supported functions
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.