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.

Use Properties to Control iOS Sensor Acquisition

The MATLAB® Support Package for Apple iOS Sensors includes properties that display current sensor values, enable and disable sensors from MATLAB, turn logging on and off, set sample rate, and show connection and logging status.

You can use the following properties with the mobiledev object.

PropertyDescription and Values
Connected

Show the status of the connection between MATLAB Mobile™ and the mobiledev object in MATLAB. Read-only. Possible values are 0 for not connected and 1 for connected. To display the status of connection for a mobiledev object m:

m.Connected

Logging

Show and control the status of data transfer from the device to MATLAB. Possible values are 0 for not logging and 1 for logging . To display the status of logging for a mobiledev object m:

m.Logging

To turn logging on or off:

m.Logging = 1 or m.Logging = 0

InitialTimestamp

Time in milliseconds, in dd-mm-yyyy HH:MM:SS.FFF format, when the first data point was transferred from the device to the mobiledev object. To display the initial timestamp for a mobiledev object m:

m.InitialTimestamp

SampleRateSample rate of the acquisition from your device, in Hz. The value is a double and must be in the range of 0 to 100 Hz. The default sample rate is 10 Hz. In addition to setting a specific numeric value, you can also use the character vector values 'high', 'medium', and 'low', which have the following values:

high 100 Hz

medium 10 Hz

low 1 Hz

AccelerationCurrent acceleration reading in X, Y, and Z coordinates, in m/s^2 (meters per second squared).

Acceleration is defined in relation to the X, Y and 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 device.

AngularVelocityCurrent angular velocity reading in X, Y, and Z rotations, in radians per second.

Angular Velocity is defined in relation to the X, Y and Z axes and in standard right-hand rotational vector notation. 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 device.

Orientation Current orientation reading in X, Y, and Z coordinates, in degrees, for azimuth, pitch, and roll.

Orientation is defined in relation to the X, Y and 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 device.

Azimuth is the angle between the positive Y-axis and magnetic north, and its range is between -180 and 180 degrees.

Positive Roll is defined when the device is lying flat on a surface and the positive Z-axis tilts towards the positive X-axis, and its range is between -180 and 180 degrees.

Positive Pitch is defined when the device is lying flat on a surface and the positive Z-axis tilts towards the positive Y-axis, and its range is between -90 and 90 degrees.

MagneticFieldCurrent magnetic field reading in X, Y, and Z coordinates, in microtesla.

Magnetic field is defined in relation to the X, Y and 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 device.

Latitude

Current latitude reading, in degrees relative to the equator, with positive values indicating latitudes north of the equator.

Longitude

Current longitude reading, in degrees relative to the zero meridian, with positive values extending east of the meridian.

HorizontalAccuracy

Current horizontal accuracy, in meters defined by a circle around the latitude and longitude.

Altitude

Current altitude reading, in meters above sea level.

Course

Current course reading, in degrees relative to true north.

Speed

Current speed reading, in meters per second.

AccelerationSensorEnabled

Turn Acceleration sensor on or off.

To turn sensor on or off:

m.AccelerationSensorEnabled = 1

m.AccelerationSensorEnabled = 0

AngularVelocitySensorEnabledTurn Angular Velocity sensor on or off.

To turn sensor on or off:

m.AngularVelocitySensorEnabled = 1

m.AngularVelocitySensorEnabled = 0

MagneticSensorEnabledTurn Magnetic Field sensor on or off.

To turn sensor on or off:

m.MagneticSensorEnabled = 1

m.MagneticSensorEnabled = 0

OrientationSensorEnabledTurn Orientation sensor on or off.

To turn sensor on or off:

m.OrientationSensorEnabled = 1

m.OrientationSensorEnabled = 0

PositionSensorEnabledTurn Position sensor on or off.

To turn sensor on or off:

m.PositionSensorEnabled = 1

m.PositionSensorEnabled = 0

Object Properties

The Connected property is read-only and shows the status of the connection between MATLAB Mobile and the mobiledev object in MATLAB. Possible values are 0 for not connected and 1 for connected.

To display the status of the connection, for a mobiledev object m:

m.Connected

The Logging property shows the status of data transfer from the device to MATLAB. Possible values are 0 for not logging and 1 for logging.

To display the status of logging, for a mobiledev object m:

m.Logging

The Logging property is also used to enable and disable logging. To begin logging data from the selected sensors, enable the property.

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.

You stop logging data from the selected sensors by disabling the Logging property.

m.Logging = 0

This action stops the transmitting of data from all selected sensors. You can also stop transmission by tapping the Stop button in MATLAB Mobile.

Sensor Reading Properties

Use the sensor reading properties to display the current reading of the sensor. At any time you can display the current reading of any of the sensors that are being logged. The Acceleration, AngularVelocity, Orientation, and MagneticField properties display the current readings from their respective sensors. If the Position sensor is logging, you can get individual position readings using the Latitude, Longitude, Speed, Course, Altitude, and HorizontalAccuracy properties.

To get the current value from a sensor, use <objectname>.<propertyname>. For example, to get the acceleration reading, for object m:

m.Acceleration

To get the longitude reading from the Position sensor:

m.Longitude

See Device Orientation for a diagram showing the X, Y, and Z axes relative to the device.

Sensor Control Properties

The support package has five properties to control the sensors from MATLAB. You can perform the same actions by selecting or deselecting the sensor buttons in MATLAB Mobile. Each control property has two possible values: 1 for on or enabled, and 0 for off or disabled.

For example, to turn the Acceleration sensor on:

m.AccelerationSensorEnabled = 1

To turn the Acceleration sensor off:

m.AccelerationSensorEnabled = 0

Sample Rate Property

This property is the sample rate of the data acquisition from your device, in Hz. The value is a double and must be a positive number in the range of 0 to 100 Hz. The default sample rate is 10 Hz.

In addition to setting a specific numeric value, you can also use the character vector values 'high', 'medium', and 'low'. These settings use the following values:

  • high – 100 Hz

  • medium – 10 Hz

  • low – 1 Hz

You can change the sample rate even after you start logging data. For example, to change the sample rate to a specific value in Hz for mobiledev object m:

m.SampleRate = 100

To change the sample rate to one of the character vector values:

m.SampleRate = 'low'

Note that the versions of the support package prior to R2016a supported setting a sample rate using the character vector values. Starting in R2016a, you can use the character vector values or specify a numeric value.