Return logged magnetic field data from Android sensor
Get Logged Magnetic Field Data from Android Sensor
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 Install MATLAB Mobile on Your Android Device and Sign In to the Cloud.
Start MATLAB Mobile on your Android device.
On the Sensors of MATLAB Mobile, tap the Magnetic Field sensor.
Place the device where you want to get the sensor data, if a remote location.
On your computer, create a
m, in MATLAB.
m = mobiledev
Begin logging data by enabling the
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 on the device.
Get the logged magnetic field data.
[mf, t] = magfieldlog(m)
This returns the magnetic field log, where
contains the three data points in
Z coordinates, in
See Device Orientation for a diagram showing the
Z axes relative to
log — Name of variable for magnetic field log data
Name of variable for magnetic field log data, returned as an
m-by-3 matrix of data points from the
Magnetic Field sensor on the Android device. The three data points are the magnetic field
Z coordinates, in microtesla.
Magnetic field is defined in relation to the
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
timestamp — Name of variable for timestamp
Name of variable for timestamp, returned as an
m-by-1 vector of timestamps from the Magnetic
Field sensor on the Android device. Time is in seconds, relative to