You can stream sensor data to MATLAB® running in the MathWorks® cloud in real-time with a WiFi or cellular connection.
Mobile™ includes the command-line interface in MATLAB and the ability to interact with iOS sensors. To connect to sensors on
the device and collect data, you create a
mobiledev object in
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 the cloud. 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 Log Sensor Data Locally (MATLAB Mobile for iOS).
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 (MATLAB Mobile for iOS). Then, process the acquired images. For an example, see Classify Images from iOS Camera Using Pretrained Network (MATLAB Mobile for iOS).
Use MATLAB to process sensor data in various ways, including creating plots. For an example of acquiring data and plotting it, see Use Logged Sensor Data Example (MATLAB Mobile for iOS).
To use iOS sensors with MATLAB Mobile, make sure you have the following:
Installation of MATLAB Mobile on your iOS device. You can acquire this application through the App Store.
iOS 8 or later on your device.
To stream or upload sensor data to the MathWorks cloud, you must have a MathWorks Account. If you do not have an account, you can set one up in MATLAB Mobile.
To open the Sensors screen in MATLAB Mobile, tap Sensors on the menu.
Turn the sensors on and off using their icons at the top of the screen.
The sensor buttons display in this order across the top of the screen, and show these measurements:
Acceleration — Acceleration reading in
coordinates, in m/s2 (meters per second
Magnetic Field — Magnetic field reading in
coordinates, in microtesla
Orientation — Position reading in
coordinates, in degrees, for azimuth, pitch, and roll
Angular Velocity — Angular velocity reading in
rotations, in radians per second
Position — Data points representing latitude, longitude, speed, course, altitude, and horizontal accuracy. Position data is obtained from GPS, Wi-Fi®, or the cellular network, using whichever is available. The measurements are:
Latitude in degrees relative to the equator, with positive values indicating latitudes north of the equator
Longitude in degrees relative to the zero meridian, with positive values extending east of the meridian
Speed in meters per second
Course in degrees relative to true north
Altitude in meters above sea level
Horizontal Accuracy in meters defined by a circle around the latitude and longitude
When you tap a sensor, the measurement readings begin and are displayed below the buttons in the order in which you select the sensors. In this example, Acceleration and Orientation have been selected.
After you have selected one or more sensors, use the Start button to send the data to MATLAB on the MathWorks cloud. See Stream Sensor Data with Sensor Controls (MATLAB Mobile for iOS).
You can also start the transmission of data from MATLAB programmatically using the
Logging property of the
mobiledev object. See Stream Sensor Data with mobiledev.logging Property (MATLAB Mobile for iOS).
Use the Sensors settings to manage sensor data collection on your device. To view the sensor settings, tap the menu icon and then tap the settings icon . Find the Sensor Settings section.
The options are:
Configure — Configure MATLAB Mobile sensor settings.
Getting Started with Sensors — Access Getting Started information for sensors.
Tap Configure to display the Sensor Settings screen.
You can configure the following settings for sensor data collection:
Sensors — Controls MATLAB access to the sensors. The access is on by default and needs to remain on in order to control the sensors and data streaming from MATLAB.
Camera — Controls MATLAB access to the cameras. The access is on by default and needs to remain on in order to control camera input from MATLAB.
Send Position Data in Background — This setting is off by default, but you can turn it on to continue to send Position data when the application goes into the background on the device.
Upload Folder — The destination folder for
uploading log files. The default folder is
Drive/MobileSensorData. You can change the destination folder
in this setting.
Auto Upload — This setting determines how data log files are uploaded to MATLAB Drive™.
Enabled — If Auto Upload is on, and you have a network connection on your device, log files are automatically uploaded to MATLAB Drive. If Auto Upload is on and you do not currently have a network connection, the files will automatically upload the next time the device detects a network connection (WiFi or cellular, if selected).
Disabled — If Auto Upload is off, you must manually upload the file to your MATLAB Drive. See Step 2. Transfer Sensor Logs (MATLAB Mobile for Android).
If you are using Wi-Fi as your connection method, the Wi-Fi on your device may have a sleep setting that you should adjust.
The Acceleration, Angular Velocity, Magnetic Field, and Orientation sensors all
log data in relation to the
Z axes. This diagram shows these axes relative to the
Note that the Z axis is a positive value when the device is lying flat on a surface. This is by design and is consistent with MATLAB conventions. When the device lies flat on a surface, the acceleration value along the Z axis is +9.81, which corresponds to the acceleration of the device (0 m/s^2) minus the acceleration of gravity (-9.81 m/s^2).