This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

readMagneticField

Read the magnetic field measured by the Magnetometer along the x, y and z axis

Syntax

magField = readMagneticField(mysh)
[magField,Ts] = readMagneticField(mysh)
magFieldRaw = readMagneticField(mysh,raw)
[magFieldRaw,Ts]= readMagneticField(mysh,raw)

Description

example

magField = readMagneticField(mysh) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes.

The unit of measurement for the Magnetometer raw data is microtesla (µT).

example

[magField,Ts] = readMagneticField(mysh) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes with timestamp. The unit of measurement for the Magnetometer field is microtesla (µT).

example

magFieldRaw = readMagneticField(mysh,raw) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes. The ‘raw’ argument is to specify that the output should be a uncalibrated raw data.

example

[magFieldRaw,Ts]= readMagneticField(mysh,raw) returns the magnetic field measured by the Magnetometer along the x, y, and the z axes with timestamp. The ‘raw’ argument is to specify that the output should be a uncalibrated raw data.

The full scale range for the Magnetometer is +/- 4 gauss.

Sense HAT IMU sensor axis information is shown below.

Examples

collapse all

To read the magnetic field along the x, y, and the z axis.

magField = readMagneticField(mysh) 
magField =  

      -0.3045    0.2769   10.0417 

Read the magnetic field measured by the Magnetometer along the x, y, and the z axis .

To read the magnetic field along the x, y, and the z axes measured by the Magnetometer along with the time stamp at which the data was read.

[magField,ts] = readMagneticField(mysh)  
magField= 

 -0.1847    0.5511    0.1847 

ts =  

   09-Aug-2016 15:37:19  

Read the magnetic field measured by the Magnetometer along the x, y, and the z axis with timestamp.

To read raw uncalibrated magnetic field along the x, y, and the z axis.

magFieldRaw = readMagneticField(mysensehat,'raw')
magFieldRaw = 

         865       -1189        2002 

Read the raw uncalibrated magnetic field value measured by the Magnetometer along the x, y, and the z axis .

To read raw uncalibrated magnetic field along the x, y, and the z axis.

[magFieldRaw,ts] = readMagneticField(mysensehat,'raw') 
magFieldRaw= 

         865       -1189        2002 

ts = 

  09-Aug-2016 15:37:19 
 

Read the raw uncalibrated magnetic field value measured by the Magnetometer along the x, y, and the z axis with the timestamp.

Input Arguments

collapse all

Connection to a SenseHAT board, specified as a sensehat object.

Argument to specify that the output should be a uncalibrated raw data.

Output Arguments

collapse all

The magnetic field measured by the Magnetometer along the x,y, and z axes. This is a 1x3 double data. The unit of measurement for the Magnetometer data is microtesla (µT).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2016b