: strs = angltostr (angles)
: strs = angltostr (angles, hemcode)
: strs = angltostr (angles, hemcode, unit)
: strs = angltostr (angles, hemcode, unit, prec)

Convert numerical angle values (Lat and/or Lon) into cellstr text values.

Inputs:

  • angles is a scalar or any array of angular values in degrees. In case unit is specified as radians, angles is supposed to be in radians as well.
  • hemcode (optional), used for indicating the hemisphere, can be one of "ew", "ns", "pm" or "none" (default), all case-insensitive. Depending on the sign of the input angle(s), the output strings have a trailing "E", "W", "N" or "S" character in case of hemcode = "ew" or "ns", a leading "+"or "-" in case of hemcode = "pm", or just a leading "-" or negative output values in case of hemcode = "none". angltostr.m is forgiving: "we", "sn", "mp" and "no" are also accepted and any empty value will be recognized as "none".
  • unit (optional, case-insensitive) describes the output format. * "degrees" (default): decimal degrees (~ -110.5320)
    * "degrees2dm": integer degrees and real minutes (94°55.980’W)
    * "degrees2dms": integer degrees and minutes and real seconds (~ 4°55’58.8"S)
    * "radians": real radian "values" (~ +3.141593)
  • prec indicates the desired number of decimal places; it’s equal to abs(prec).

The output is a cell array of strings, one cell for each angle value, the same shape as the input array. To convert it to more Matlab-compatible output, just apply char() to get a char string or char array.

Furthermore, unlike its Matlab sibling angl2str, angltostr will map output values into the [-180, 180] interval and adjust output hemisphere indicators ("E", "W", "N", "S" or just "-" or "+") accordingly. For latitudes this works similarly only if "ns" was specified for hemcode; in all other cases output must be postprocessed manually to map absolute latitudes > 90 degrees into (180-lat) * sign(lat); analogously for radians.

See also: angl2str, str2angle.

Package: mapping