⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 q2.m

📁 关于全球若干大城市之间最短距离问题的解决
💻 M
字号:
clc
syms city no;
syms LONG1 LONG2 lat1 lat2 LONG_degree lat_degree;
syms xi yi zi xj yj zj;
syms R d_ij l_ij_1 l_ij_2;
syms temp0 temp1 temp2;
syms x_o y_o z_o
R= input('please input the earth Radius:');
[city LONG1 LONG2 lat1 lat2 no]=textread('data2.txt','%s%f%f%f%f%d','headerlines',0)
%get the city of shanghai 's coordinate     
LONG_degree=LONG1(5)+LONG2(5)/60;
lat_degree=lat1(5)+lat2(5)/60;
xj=R*cos(LONG_degree)*cos(lat_degree);
yj=R*sin(LONG_degree)*cos(lat_degree);
zj=R*sin(lat_degree);
% end
[city_2 LONG1_2 LONG2_2 lat1_2 lat2_2 no_2]=textread('data2.txt','%s%f%f%f%f%d','headerlines',0)
no_1=input('please input the city u want to found:');
    LONG_degree=LONG1(no_1)+LONG2(no_1)/60;
    lat_degree=lat1(no_1)+lat2(no_1)/60;
    xi=R*cos(LONG_degree)*cos(lat_degree);
    yi=R*sin(LONG_degree)*cos(lat_degree);
    zi=R*sin(lat_degree);
    [xc yc zc]=solve('x(i)*xc+y(i)*yc+z(i)*zc=0','x(5)*xc+y(5)*yc+z(5)*zc=0','xc^2+yc^2+zc^2=R^2','xc,yc,zc');
    C=[0-xc 0-yc R-zc];
    [city_3 LONG1_3 LONG2_3 lat1_3 lat2_3]=textread('data3.txt','%s%f%f%f%f','headerlines',0)
    for j=1:213
        LONG_degree=LONG1_3(j)+LONG2_3(j)/60;
        lat_degree=lat1_3(j)+lat2_3(j)/60;
        xj=R*cos(LONG_degree)*cos(lat_degree);
        yj=R*sin(LONG_degree)*cos(lat_degree);
        zj=R*sin(lat_degree);
        A=[x_o y_o z_o]; 
        x_o=xj+C;
        y_o=yj+C;
        z_o=zj+C;
        A=[x_o y_o z_o]; 
    end
    min(A)
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -