# dcmecef2ned

Convert geodetic latitude and longitude to direction cosine matrix

## Syntax

```n = dcmecef2ned(lat, lon) ```

## Description

`n = dcmecef2ned(lat, lon)` calculates the direction cosine matrix, `n`, for a given set of geodetic latitude and longitude, `lat`, `lon`. `lat` is an `m` array of geodetic latitudes. `lon` is an `m` array of longitudes. Latitude and longitude values can be any value. However, latitude values of +90 and -90 may return unexpected values because of singularity at the poles. `n` returns a 3-by-3-by-`m` matrix containing `m` direction cosine matrices. `n` performs the coordinate transformation of a vector in Earth-centered Earth-fixed (ECEF) axes into a vector in north-east-down (NED) axes. Geodetic latitudes and longitudes are input in degrees.

## Examples

Determine the direction cosine matrix from geodetic latitude and longitude:

```lat = 45; lon = -122; dcm = dcmecef2ned(lat, lon) dcm = 0.3747 0.5997 0.7071 0.8480 -0.5299 0 0.3747 0.5997 -0.7071```

Determine the direction cosine matrix from multiple geodetic latitudes and longitudes:

```lat = [45 37.5]; lon = [-122 -85]; dcm = dcmecef2ned(lat, lon) dcm(:,:,1) = 0.3747 0.5997 0.7071 0.8480 -0.5299 0 0.3747 0.5997 -0.7071 dcm(:,:,2) = -0.0531 0.6064 0.7934 0.9962 0.0872 0 -0.0691 0.7903 -0.6088``` 