📄 q1.m
字号:
%syms Lij R D d1 d2 d3 d4 city no;
%A=[city,d1,d2,d3,d4,no];
%A=textread('data1.txt','%s,%f,%f,%f,%f,%d')
%R= input('please input the earth Radius:');
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;
R= input('please input the earth Radius:');
[city LONG1 LONG2 lat1 lat2 no]=textread('data1.txt','%s%f%f%f%f%d','headerlines',0)
%fidin=fopen('data1.txt'); % 打开test2.txt文件
%fidout=fopen('mkmatlab.txt','w'); % 创建MKMATLAB.txt文件
%while ~feof(fidin) % 判断是否为文件末尾
% tline=fgetl(fidin); % 从文件读行
% if double(tline(1))>=48&&double(tline(1))<=57 % 判断首字符是否是数值
% fprintf(fidout,'%s\n\n',tline); % 如果是数字行,把此行数据写入文件MKMATLAB.txt
% continue % 如果是非数字继续下一次循环
% end
%end
%fclose(fidout);
%MK=importdata('MKMATLAB.txt');
%A=
%[city LONG1 LONG2 lat1 lat2 no]=textread('data1.txt','%s%f%f%f%f%d','headerlines',1)
%get the city of shanghai 's coordinate
LONG_degree=LONG1(36)+LONG2(36)/60;
lat_degree=lat1(36)+lat2(36)/60;
xj=R*cos(LONG_degree)*cos(lat_degree);
yj=R*sin(LONG_degree)*cos(lat_degree);
zj=R*sin(lat_degree);
% get the city of shanghai 's coordinate end
for i=1:35
no(i)
city(i)
LONG_degree=LONG1(i)+LONG2(i)/60;
lat_degree=lat1(i)+lat2(i)/60;
xi=R*cos(LONG_degree)*cos(lat_degree);
yi=R*sin(LONG_degree)*cos(lat_degree);
zi=R*sin(lat_degree);
temp0=(xi-xj)^2+(yi-yj)^2+(zi-zj)^2;
d_ij=sqrt(temp0);
temp1=1-(d_ij^2)/(2*R^2);
l_ij_1=R*abs(acos(temp1));
l_ij_1
temp2=(xi*xj+yi*yj+zi*zj)/(R^2);
l_ij_2=R*abs(acos(temp2));
l_ij_2
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -