Main Content

intrplat

Interpolate latitude at specified longitude

    Description

    latq = intrplat(lon,lat,lonq) returns a latitude that corresponds to the specified query longitude lonq by interpolating the specified latitude-longitude coordinates. By default, the function uses linear interpolation and assumes that the coordinates are in degrees.

    example

    latq = intrplat(lon,lat,lonq,method) specifies the interpolation method.

    example

    latq = intrplat(lon,lat,lonq,method,units) specifies the angle units for the input coordinates and output coordinates.

    Examples

    collapse all

    Specify the sample longitudes and latitudes. The sample longitudes must be strictly increasing or strictly decreasing.

    lon = [1 3 4 9 13];
    lat = [57 68 60 65 56];

    Specify the query longitudes. Then, calculate interpolated latitudes that correspond to the query longitudes. By default, the intrplat function uses linear interpolation.

    lonq = [2.4 7.3];
    latq = intrplat(lon,lat,lonq)
    latq = 2×1
    
       64.7000
       63.3000
    
    

    Specify the sample longitudes and latitudes. The sample longitudes must be strictly increasing or strictly decreasing.

    lon = [1 13 24 39 43];
    lat = [-37 -18 2 15 29];

    Specify the query longitudes. Then, calculate interpolated latitudes that correspond to the query longitudes. By default, the intrplat function uses linear interpolation.

    lonq = [8.9 27.3 42.6];
    latq = intrplat(lon,lat,lonq)
    latq = 3×1
    
      -24.4917
        4.8600
       27.6000
    
    

    Calculate the interpolated latitudes again, this time using great circle interpolation.

    latqGC = intrplat(lon,lat,lonq,"gc")
    latqGC = 3×1
    
      -25.3577
        4.9697
       27.7341
    
    

    Input Arguments

    collapse all

    Sample longitude coordinates, specified as a vector of strictly increasing or strictly decreasing values. The size of lon must match the size of lat.

    By default, the intrplat function assumes that the coordinates are in degrees. To use coordinates in radians, specify the units argument as "radians".

    Data Types: single | double

    Sample latitude coordinates, specified as a vector. The size of lat must match the size of lon.

    By default, the intrplat function assumes that the coordinates are in degrees. To use coordinates in radians, specify the units argument as "radians".

    Data Types: single | double

    Query longitude coordinates, specified as a scalar or vector. The coordinates must be within the range of values specified by lon.

    By default, the intrplat function assumes that the coordinates are in degrees. To use coordinates in radians, specify the units argument as "radians".

    Data Types: single | double

    Interpolation method, specified as one of these options:

    • "linear" — Interpolate points along linear paths.

    • "pchip" — Use piecewise cubic Hermite interpolation.

    • "gc" — Interpolate points along great circle paths.

    • "rh" — Interpolate points along rhumb line paths.

    For more information about rhumb lines and great circles, see Comparison of Rhumb Lines and Great Circles.

    Angle unit for the coordinates, specified as one of these options:

    • "degrees" — Degrees

    • "radians" — Radians

    Output Arguments

    collapse all

    Interpolated latitude coordinates, returned as a scalar or vector. The size of latq matches the size of lonq.

    Tips

    • The intrplat function is a geographic version of the interp1 function.

    • To interpolate longitude at a given latitude, use the intrplon function.

    Version History

    Introduced before R2006a