Documentation

## Angles as Binary and Formatted Numbers

The terms decimal degrees and decimal minutes are often used in geospatial data handling and navigation. The preceding section avoided using them because its focus was on the representation of angles within MATLAB, where they can be arbitrary binary floating-point numbers.

However, once an angle in degrees is converted to a character vector, it is often helpful to describe that value as representing the angle in decimal degrees. Thus,

```num2str(rad2deg(1)) ans = 57.2958```
gives a value in decimal degrees. In casual communication it is common to refer to a quantity such as `rad2deg(1)` as being in decimal degrees, but strictly speaking, that is not true until it is somehow converted to a character vector in base 10. That is, a binary floating-point number is not a decimal number, whether it represents an angle in degrees or not. If it does represent an angle and that number is then formatted and displayed as having a fractional part, only then is it appropriate to speak of "decimal degrees." Likewise, the term "decimal minutes" applies when you convert a degrees-minutes representation to a character vector, as in
```num2str(degrees2dm(rad2deg(1))) ans = 57 17.7468```

### Formatting Latitudes and Longitudes

When a DM or DMS representation of an angle is expressed as a character vector, it is traditional to tag the different components with the special characters `d`, `m`, and `s`, or °, ', and ".

When the angle is a latitude or longitude, a letter often designates the sign of the angle:

• `N` for positive latitudes

• `S` for negative latitudes

• `E` for positive longitudes

• `W` for negative longitudes

For example, 123 degrees, 30 minutes, 12.7 seconds west of Greenwich can be written as 123d30m12.7sW, 123° 30° 12.7" W, or -123° 30° 12.7".

Use the function `str2angle` to import latitude and longitude data formatted as such character vectors. Conversely, you can format numeric degree data for display or export with `angl2str`, or combine `degrees2dms` or `degrees2dm` with `sprintf` to customize formatting.

See Degrees, Minutes, and Seconds for more details about DM and DMS representation.

##### Support Get trial now