Main Content

magfieldlog

Return logged magnetic field data from mobile device sensor

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.

[log, timestamp] = magfieldlog(m) returns the magnetic field log, where m is the name of the mobiledev object that acquires the sensor data. log is an N-by-3 matrix containing magnetic field data points, and timestamp is an N-by-1 vector of timestamps, where N is the number of acquired samples.

example

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.

Start MATLAB Mobile on your mobile device.

On the Sensors screen, tap the Magnetic Field sensor.

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

In your MATLAB session, create a mobiledev object, m.

m = mobiledev

Begin logging data by enabling the Logging property.

m.Logging = 1

This action starts the transmitting of data from all selected sensors. You can also start transmission by tapping the Start button in MATLAB Mobile.

Get the logged magnetic field data.

[mf, t] = magfieldlog(m)

This returns the magnetic field log, where mf contains the three data points in X, Y, and Z coordinates, in microtesla.

See Device Orientation for a diagram showing the X, Y, and Z axes relative to the device.

Output Arguments

collapse all

Name of variable for magnetic field log data, returned as an N-by-3 matrix of data points from the Magnetic Field sensor on the mobile device. The three data points are the magnetic field reading in X, Y, and Z coordinates, in microtesla.

Magnetic field is defined in relation to the X, Y and Z axes. If you place the device face-up on a table, the positive X-axis extends out of the right side of the device, positive Y-axis extends out of the top side, and the positive Z-axis extends out of the front face of the device. This is independent of the orientation of the device.

Name of variable for timestamp, returned as an N-by-1 vector of timestamps from the Magnetic Field sensor on the mobile device. Time is in seconds, relative to the InitialTimestamp property.

Version History

Introduced in R2015a