# insMagnetometer

Model magnetometer readings for sensor fusion

Since R2022a

## Description

The insMagnetometer object models magnetometer readings for sensor fusion. Passing an insMagnetometer object to an insEKF object enables the insEKF object to fuse magnetometer data. For details on the magnetometer model, see Algorithms.

## Creation

### Description

example

sensor = insMagnetometer creates an insMagnetometer object. Passing the created sensor to an insEKF object enables the insEKF object to fuse magnetometer data. When fusing data with the fuse object function of insEKF, pass sensor as the second argument to identify the data as obtained from a magnetometer.

## Examples

collapse all

Create an insMagnetometer object and pass it to an insEKF object.

sensor = insMagnetometer;
filterOrientation = insEKF(sensor)
filterOrientation =
insEKF with properties:

State: [13x1 double]
StateCovariance: [13x13 double]
MotionModel: [1x1 insMotionOrientation]
Sensors: {[1x1 insMagnetometer]}
SensorNames: {'Magnetometer'}
ReferenceFrame: 'NED'

Show the state information of the filter. Notice that the state contains the geomagnetic vector component and the magnetometer bias component.

stateinfo(filterOrientation)
ans = struct with fields:
Orientation: [1 2 3 4]
AngularVelocity: [5 6 7]
GeomagneticVector: [8 9 10]
Magnetometer_Bias: [11 12 13]

Fuse a magnetometer reading of [27 -2 -16] $\mu \mathrm{T}$ with a measurement noise of diag([0.1 0.1 0.1]) ${\mu \mathrm{T}}^{2}$.

measure = [27 -2 -16];
measureNoise = diag([0.1 0.1 0.1]);

fuse(filterOrientation,sensor,measure,measureNoise)
ans = 13×1

1.0000
-0.0032
-0.0032
-0.0050
0
0
0
27.5550
-2.4168
-16.0849
⋮

## Algorithms

The insMagnetometer object models the magnetometer reading as the geomagnetic vector in the sensor frame. The measurement equation is:

$h\left(x\right)={g}_{mag}+\Delta$

where h(x) is the three-dimensional measurement output, gmag is the geomagnetic vector expressed in the sensor frame, and Δ is the three-dimensional bias of the sensor, which is modeled as a constant vector in the sensor frame.

Passing an insMagnetometer object to an insEKF filter object enables the filter object to additionally track the unique geomagnetic vector, as well as the bias of the magnetometer.

## Version History

Introduced in R2022a