# interpm

Densify latitude-longitude sampling in lines or polygons

## Syntax

```[latout,lonout] = interpm(lat,lon,maxdiff) [latout,lonout] = interpm(lat,lon,maxdiff,method) [latout,lonout] = interpm(lat,lon,maxdiff,method,units) ```

## Description

`[latout,lonout] = interpm(lat,lon,maxdiff)` fills in any gaps in latitude (`lat`) or longitude (`lon`) data vectors that are greater than a defined tolerance `maxdiff` apart in either dimension. The angle units of the three inputs need not be specified, but they must be identical. `latout` and `lonout` are the new latitude and longitude data vectors, in which any gaps larger than `maxdiff` in the original vectors have been filled with additional points. The default method of interpolation used by `interpm` is linear.

`[latout,lonout] = interpm(lat,lon,maxdiff,method)` interpolates between vector data coordinate points using a specified interpolation `method`. Valid interpolation methods are `'gc'` for great circle, `'rh'` for rhumb line, and `'lin'` for linear interpolation.

`[latout,lonout] = interpm(lat,lon,maxdiff,method,units)` specifies the units used, where `units` is any valid angle unit. The default is `'degrees'`.

## Examples

collapse all

Define two vectors containing the latitude and longitude values for a set of vertices. In `lat`, note that a gap of 2 degrees exists between the values 2 and 4. Similarly, in `lon`, a gap of 2 degrees exists between the values 1 and 3.

```lat = [1 2 4 5]; lon = [1 3 4 5];```

Call `interpm` to fill in any gaps greater than 1 degree in either vector. For example, `interpm` interpolates and inserts the value 2 into the `lon` vector to fill the gap between the values 1 and 3, and inserts the value 1.5 in the `lat` vector for this new vertex. Similarly, `interpm` inserts the value 3 into the `lat` vector to fill the gap between the values 2 and 4, and inserts the value 3.5 in the `lon` vector for this new vertex. Now, the separation of adjacent vertices is no greater than `maxdiff` in either `newlat` or `newlon`.

```maxdiff = 1; [newlat,newlon] = interpm(lat,lon,maxdiff)```
```newlat = 6×1 1.0000 1.5000 2.0000 3.0000 4.0000 5.0000 ```
```newlon = 6×1 1.0000 2.0000 3.0000 3.5000 4.0000 5.0000 ```

## Version History

Introduced before R2006a