function[YAW,PIT]=result_fixerror(B1,L1,H1,B2,L2,H2) %%这是被调用函数
B1=B1*pi/180;
L1=L1*pi/180;
H1=H1;
B2=B2*pi/180;
L2=L2*pi/180;
H2=H2;
a=6378137;
e=0.006694379995;
N1=a./sqrt(1-e*sin(B1).*sin(B1));
X1=(N1+H1).*cos(B1).*cos(L1);
Y1=(N1+H1).*cos(B1).*sin(L1);
Z1=(N1.*(1-e)+H1).*sin(B1);
N2=a./sqrt(1-e*sin(B2).*sin(B2));
X2=(N2+H2)*cos(B2)*cos(L2);
Y2=(N2+H2)*cos(B2)*sin(L2);
Z2=(N2*(1-e)+H2)*sin(B2);
x = (-sin(L2)).*(X1-X2)+(cos(L2)).*(Y1-Y2);
y =(-sin(B2).*cos(L2).*(X1-X2))+(-sin(B2).*sin(L2).*(Y1-Y2))+cos(B2).*(Z1-Z2);
z = (cos(B2).*cos(L2)).*(X1-X2)+(cos(B2).*sin(L2)).*(Y1-Y2)+sin(L2).*(Z1-Z2);
YAW=180.*atan(y./x)./pi;
PIT=180.*atan(z./sqrt(x.^2+y.^2))/pi;
——————————————————————————————————————
B1=str2double(get(handles.edit18,'string'));
L1=str2double(get(handles.edit19,'string'));
H1=str2double(get(handles.edit20,'string'));
B2=str2double(get(handles.edit6,'string'));
L2=str2double(get(handles.edit7,'string'));
H2=str2double(get(handles.edit8,'string'));
B1_value=str2double(get(handles.edit21,'string'));
L1_value=str2double(get(handles.edit22,'string'));
H1_value=str2double(get(handles.edit23,'string'));
B2_value=str2double(get(handles.edit12,'string'));
L2_value=str2double(get(handles.edit13,'string'));
H2_value=str2double(get(handles.edit14,'string'));
[YAW,PIT]=result_fixerror(B1,L1,H1,B2,L2,H2);
[YAW0,PIT0]=result_fixerror(B1+B1_value,L1+L1_value,H1+H1_value,B2+B2_value,L2+L2_value,H2+H2_value);
detayaw=abs(YAW-YAW0);
detapit=abs(PIT-PIT0);
set(handles.text47,'String',detayaw);
set(handles.text48,'String',detapit);
guidata(hObject, handles);
我反复查了N遍。。不知道哪出错了 能运行但是结果不对,望指点:handshake
[本帖最后由 mooni 于 2009-5-14 09:24 编辑]