24小时热门版块排行榜    

查看: 1203  |  回复: 3

狱-地为理-梨

金虫 (小有名气)

[求助] matlab 编程求北京到纽约的距离和方位角 已有3人参与

matlab 编程求北京到纽约的距离和北京到纽约的方位角和纽约到北京的方位角
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

水晶杯喝茶

新虫 (正式写手)

【答案】应助回帖

有公式吗,有的话容易
2楼2014-10-24 13:39:59
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

杨小胖

金虫 (正式写手)

【答案】应助回帖

计算距离的,方位角的再找找看吧,或者代码稍微修改下
=========================
function dist = pos2dist(lag1,lon1,lag2,lon2,method)
% function dist = pos2dist(lag1,lon1,lag2,lon2,method)
% calculate distance between two points on earth's surface
% given by their latitude-longitude pair.
% Input lag1,lon1,lag2,lon2 are in degrees, without 'NSWE' indicators.
% Input method is 1 or 2. Default is 1.
% Method 1 uses plane approximation,
% only for points within several tens of kilometers (angles in rads):
% d =
% sqrt(R_equator^2*(lag1-lag2)^2 + R_polar^2*(lon1-lon2)^2*cos((lag1+lag2)/2)^2)
% Method 2 calculates sphereic geodesic distance for points farther apart,
% but ignores flattening of the earth:
% d =
% R_aver * acos(cos(lag1)cos(lag2)cos(lon1-lon2)+sin(lag1)sin(lag2))
% Output dist is in km.
% Returns -99999 if input argument(s) is/are incorrect.
% Flora Sun, University of Toronto, Jun 12, 2004.
if nargin < 4
    dist = -99999;
    disp('Number of input arguments error! distance = -99999');
    return;
end
if abs(lag1)>90 | abs(lag2)>90 | abs(lon1)>360 | abs(lon2)>360
    dist = -99999;
    disp('Degree(s) illegal! distance = -99999');
    return;
end
if lon1 < 0
    lon1 = lon1 + 360;
end
if lon2 < 0
    lon2 = lon2 + 360;
end
% Default method is 1.
if nargin == 4
    method = 1;
end
if method == 1
    km_per_deg_la = 111.3237;
    km_per_deg_lo = 111.1350;
    km_la = km_per_deg_la * (lag1-lag2);
    % Always calculate the shorter arc.
    if abs(lon1-lon2) > 180
        dif_lo = abs(lon1-lon2)-180;
    else
        dif_lo = abs(lon1-lon2);
    end
    km_lo = km_per_deg_lo * dif_lo * cos((lag1+lag2)*pi/360);
    dist = sqrt(km_la^2 + km_lo^2);
else
    R_aver = 6374;
    deg2rad = pi/180;
    lag1 = lag1 * deg2rad;
    lon1 = lon1 * deg2rad;
    lag2 = lag2 * deg2rad;
    lon2 = lon2 * deg2rad;
    dist = R_aver * acos(cos(lag1)*cos(lag2)*cos(lon1-lon2) + sin(lag1)*sin(lag2));
end
人生中最辉煌的不是功成名就的时候,而是在失败和挫折中看到希望并为之奋斗的日子
3楼2014-12-10 10:32:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xumi1993

新虫 (初入文坛)

【答案】应助回帖

[ARCLEN, AZ] = distance(LAT1,LON1,LAT2,LON2)
这是matlab Mapping Toolbox 里的一个函数。
输入一个点的经纬度和另一个点的经纬度。输出大圆弧长度和方位角
4楼2015-02-23 00:02:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 狱-地为理-梨 的主题更新
信息提示
请填处理意见