Read one sample of magnetic field from sensor
Create an Arduino object and include the I2C library.
Or, you can explicitly specify it in the
pair while creating the Arduino object.
clear a; a = arduino('COM4', 'Uno', 'Libraries', 'I2C');
Create the sensor object.
imu = mpu9250(a);
Return one sample of magnetic field data.
magReadings = readMagneticField(imu) magReadings = 16.2797 9.1711 -19.0969
imu— IMU sensor object
The IMU sensor object.
magReadings— Value read from the sensor
The magnetic field value on x, y, and z axes read from the sensor.