Magnetometer
R2026bMeasure magnetic field along X, Y, and Z axes
Libraries:
Simulink Support Package for Android Devices /
Sensors
Description
Add-On Required: This feature requires the Simulink Support Package for Android Devices add-on.
The Magnetometer block reads the strength of the magnetic field around an Android™ device. The built-in magnetometer sensor on the Android device measures the magnetic field along the X, Y, and Z axes. The block outputs the magnetic field as a 1-by-3 vector in microtesla (μT).
This illustration shows the orientation of the X, Y, and Z axes for a typical Android mobile phone.

This illustration shows the orientation of the X, Y, and Z axes for a typical Android tablet.

Note
During simulations without hardware, this block outputs zeros. For more information, see Block Produces Zeros or Does Nothing in Simulation.
Ports
Output
Parameters
Programmatic Use: Add Block
To add the block programmatically, use the add_block function with one of these library block paths as the source.
"androidsensorlib/Magnetometer"
Example: add_block("androidsensorlib/Magnetometer","myModel/myBlock",MakeNameUnique="on")
Version History
Introduced in R2018a

