数学建模社区-数学中国

标题: 求助 [打印本页]

作者: 孤狼1512    时间: 2016-1-23 20:52
标题: 求助
matlab里没有自带distanse函数,有没有哪个大神能帮忙写一个,万分感谢啊


作者: 冉维    时间: 2016-1-23 23:04
不是计信院院的不懂。。。

作者: madio    时间: 2016-1-24 16:12
莫非是要定义一个距离函数吗?欧式距离?

作者: 远行的小船儿666    时间: 2016-1-24 20:33
distance  Distance between points on sphere or ellipsoid

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2) computes the lengths,
    ARCLEN, of the great circle arcs connecting pairs of points on the
    surface of a sphere. In each case, the shorter (minor) arc is assumed.
    The function can also compute the azimuths, AZ, of the second point in
    each pair with respect to the first (that is, the angle at which the
    arc crosses the meridian containing the first point).  The input
    latitudes and longitudes, LAT1, LON1, LAT2, LON2, can be scalars or
    arrays of equal size and must be expressed in degrees. ARCLEN is
    expressed in degrees of arc and will have the same size as the input
    arrays.  AZ is measured clockwise from north, in units of degrees.
    When given a combination of scalar and array inputs, the scalar inputs
    are automatically expanded to match the size of the arrays.

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2,ELLIPSOID) computes
    geodesic arc length and azimuth assuming that the points lie on the
    reference ellipsoid defined by the input ELLIPSOID.  ELLIPSOID is a
    reference ellipsoid (oblate spheroid) object, a reference sphere
    object, or a vector of the form [semimajor_axis, eccentricity].  The
    output, ARCLEN, is expressed in the same length units as the semimajor
    axis of the ellipsoid.

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2,UNITS) uses the input
    string UNITS to define the angle unit of the outputs ARCLEN and AZ and
    the input latitude-longitude coordinates.  UNITS may equal 'degrees'
    (the default value) or 'radians'.

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2,ELLIPSOID,UNITS) uses the
    UNITS string to specify the units of the latitude-longitude
    coordinates, but the output range has the same units as the
    semimajor axis of the ellipsoid.

    [ARCLEN, AZ] = distance(TRACK,...) uses the input string TRACK to
    specify either a great circle/geodesic or a rhumb line arc. If TRACK
    equals 'gc' (the default value), then great circle distances are
    computed on a sphere and geodesic distances are computed on an
    ellipsoid. If TRACK equals 'rh', then rhumb line distances are computed
    on either a sphere or ellipsoid.

    [ARCLEN, AZ] = distance(PT1,PT2) accepts N-by-2 coordinate arrays
    PT1 and PT2 such that PT1 = [LAT1 LON1] and PT2 = [LAT2 LON2] where
    LAT1, LON1, LAT2, and LON2 are column vectors.  It is equivalent to
    ARCLEN = distance(PT1(:,1),PT1(:,2),PT2(:,1),PT2(:,2)).

    [ARCLEN, AZ] = distance(PT1,PT2,ELLIPSOID)
    [ARCLEN, AZ] = distance(PT1,PT2,UNITS),
    [ARCLEN, AZ] = distance(PT1,PT2,ELLIPSOID,UNITS) and
    [ARCLEN, AZ] = distance(TRACK,PT1,...) are all valid calling forms.

    Remark on Computing Azimuths
    ----------------------------
    Note that when both distance and azimuth are required for the same
    point pair(s), it's more efficient to compute both with a single
    call to distance.  That is, use:

        [ARCLEN, AZ] = distance(...);

    rather than its slower equivalent:

        ARCLEN = distance(...);
        AZ = AZIMUTH(...);

    Remark on Output Units
    ----------------------
    To express the output ARCLEN as an arc length expressed in either
    degrees or radians, omit the ELLIPSOID argument.  This is possible only
    on a sphere.  If ELLIPSOID is supplied, ARCLEN is expressed in the same
    length units as the semimajor axis of the ellipsoid.  Specify ELLIPSOID
    as [R 0] to compute ARCLEN as a distance on a sphere of radius R, with
    ARCLEN having the same units as R.

    Remark on Eccentricity
    ----------------------
    Geodesic distances on an ellipsoid are valid only for small
    eccentricities typical of the Earth (e.g., 0.08 or less).

    Remark on Long Geodesics
    ------------------------
    Distance calculations for geodesics degrade slowly with increasing
    distance and may break down for points that are nearly antipodal,
    and/or when both points are very close to the Equator.  In addition,
    for calculations on an ellipsoid, there is a small but finite input
    space, consisting of pairs in which both the points are nearly
    antipodal AND both points fall close to (but not precisely on) the
    Equator. In this case, a warning is issued and both ARCLEN and AZ
    are set to NaN for the "problem pairs."
   
    See also azimuth, reckon.

    Reference page in Help browser
       doc distance


作者: 远行的小船儿666    时间: 2016-1-24 20:33
大概是这样纸吧                          

作者: 远行的小船儿666    时间: 2016-1-24 20:34
distance  Distance between points on sphere or ellipsoid

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2) computes the lengths,
    ARCLEN, of the great circle arcs connecting pairs of points on the
    surface of a sphere. In each case, the shorter (minor) arc is assumed.
    The function can also compute the azimuths, AZ, of the second point in
    each pair with respect to the first (that is, the angle at which the
    arc crosses the meridian containing the first point).  The input
    latitudes and longitudes, LAT1, LON1, LAT2, LON2, can be scalars or
    arrays of equal size and must be expressed in degrees. ARCLEN is
    expressed in degrees of arc and will have the same size as the input
    arrays.  AZ is measured clockwise from north, in units of degrees.
    When given a combination of scalar and array inputs, the scalar inputs
    are automatically expanded to match the size of the arrays.

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2,ELLIPSOID) computes
    geodesic arc length and azimuth assuming that the points lie on the
    reference ellipsoid defined by the input ELLIPSOID.  ELLIPSOID is a
    reference ellipsoid (oblate spheroid) object, a reference sphere
    object, or a vector of the form [semimajor_axis, eccentricity].  The
    output, ARCLEN, is expressed in the same length units as the semimajor
    axis of the ellipsoid.

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2,UNITS) uses the input
    string UNITS to define the angle unit of the outputs ARCLEN and AZ and
    the input latitude-longitude coordinates.  UNITS may equal 'degrees'
    (the default value) or 'radians'.

    [ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2,ELLIPSOID,UNITS) uses the
    UNITS string to specify the units of the latitude-longitude
    coordinates, but the output range has the same units as the
    semimajor axis of the ellipsoid.

    [ARCLEN, AZ] = distance(TRACK,...) uses the input string TRACK to
    specify either a great circle/geodesic or a rhumb line arc. If TRACK
    equals 'gc' (the default value), then great circle distances are
    computed on a sphere and geodesic distances are computed on an
    ellipsoid. If TRACK equals 'rh', then rhumb line distances are computed
    on either a sphere or ellipsoid.

    [ARCLEN, AZ] = distance(PT1,PT2) accepts N-by-2 coordinate arrays
    PT1 and PT2 such that PT1 = [LAT1 LON1] and PT2 = [LAT2 LON2] where
    LAT1, LON1, LAT2, and LON2 are column vectors.  It is equivalent to
    ARCLEN = distance(PT1(:,1),PT1(:,2),PT2(:,1),PT2(:,2)).

    [ARCLEN, AZ] = distance(PT1,PT2,ELLIPSOID)
    [ARCLEN, AZ] = distance(PT1,PT2,UNITS),
    [ARCLEN, AZ] = distance(PT1,PT2,ELLIPSOID,UNITS) and
    [ARCLEN, AZ] = distance(TRACK,PT1,...) are all valid calling forms.

    Remark on Computing Azimuths
    ----------------------------
    Note that when both distance and azimuth are required for the same
    point pair(s), it's more efficient to compute both with a single
    call to distance.  That is, use:

        [ARCLEN, AZ] = distance(...);

    rather than its slower equivalent:

        ARCLEN = distance(...);
        AZ = AZIMUTH(...);

    Remark on Output Units
    ----------------------
    To express the output ARCLEN as an arc length expressed in either
    degrees or radians, omit the ELLIPSOID argument.  This is possible only
    on a sphere.  If ELLIPSOID is supplied, ARCLEN is expressed in the same
    length units as the semimajor axis of the ellipsoid.  Specify ELLIPSOID
    as [R 0] to compute ARCLEN as a distance on a sphere of radius R, with
    ARCLEN having the same units as R.

    Remark on Eccentricity
    ----------------------
    Geodesic distances on an ellipsoid are valid only for small
    eccentricities typical of the Earth (e.g., 0.08 or less).

    Remark on Long Geodesics
    ------------------------
    Distance calculations for geodesics degrade slowly with increasing
    distance and may break down for points that are nearly antipodal,
    and/or when both points are very close to the Equator.  In addition,
    for calculations on an ellipsoid, there is a small but finite input
    space, consisting of pairs in which both the points are nearly
    antipodal AND both points fall close to (but not precisely on) the
    Equator. In this case, a warning is issued and both ARCLEN and AZ
    are set to NaN for the "problem pairs."
   
    See also azimuth, reckon.

    Reference page in Help browser
       doc distance


作者: 远行的小船儿666    时间: 2016-1-24 20:36
可以的,值得看看

作者: 远行的小船儿666    时间: 2016-1-24 20:36
谢谢分享           

作者: 孤狼1512    时间: 2016-1-24 23:00
madio 发表于 2016-1-24 16:12
莫非是要定义一个距离函数吗?欧式距离?

问题解决,自己找了一个

作者: 孤狼1512    时间: 2016-1-24 23:01
远行的小船儿666 发表于 2016-1-24 20:36
可以的,值得看看

问题解决了,自己找了个合适的源程序

作者: 远行的小船儿666    时间: 2016-1-25 14:16
不错哒!                                               

作者: 远行的小船儿666    时间: 2016-1-25 14:16
不错哒!                                               





欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5