メインコンテンツ

intrplon

Interpolate longitude at specified latitude

    Description

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

    example

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

    example

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

    Examples

    collapse all

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

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

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

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

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

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

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

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

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

    lonqGC = intrplon(lat,lon,latq,"gc")
    lonqGC = 3×1
    
      -24.7649
        4.4455
       27.1770
    
    

    Input Arguments

    collapse all

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

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

    Data Types: single | double

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

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

    Data Types: single | double

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

    By default, the intrplon 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 longitude coordinates, returned as a scalar or vector. The size of lonq matches the size of latq.

    Tips

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

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

    Version History

    Introduced before R2006a