?? tle2orb.m
字號:
function sat=tle2orb(tlefile)%TLE2ORB Get Keplerian elements from Two-Line Element data.
% SAT = TLE2ORB([TLEFILE]), where SAT is an array of struct
%
% SAT(1:N).oe
% SAT(1:N).name
% SAT(1:N).epoch
%
% as described below. N is the number of satellites.
%% NAME is the satellite name,
% EPOCH is in YMDhms format and
% OE is the Keplerian orbital elements.%% The orbital elements have the format:% a [m] : semi-major axis% e [] : eccentricity% i [deg] : inclination% W [deg] : longitude of the ascending node% w [deg] : argument of perigee% M [deg] : mean anomaly at EPOCH% % The data is extracted from the text file TLEFILE with % Two-Line Element format of the satellite orbits.
% To download current satellite data go to:
%
% http://celestrak.com/NORAD/elements/
%
% Then put the file(s) in the .../sat/ directory.
%
% See also MSATTRACK, ORB2CART.% Copyright (c) 2002-12-08, B. Rasmus Anthin% Revision 2002-12-09, 2002-12-30, 2002-12-31,
% 2003-04-03, 2003-04-06, 2003-04-17,
% 2003-06-19.
curr=pwd;path=which(mfilename);
path=path(1:end-length(mfilename)-2); %additional -2 for the extension.
if nargin
if ~any(tlefile=='.')
tlefile=[tlefile '.txt'];
end
tlefile=fullfile(path,'sat',tlefile);
else
currpath=pwd;
cd(fullfile(path,'sat'))
[tlefile,tlepath]=uigetfile('*.txt','Load TLE Data');
cd(curr) if ~ischar(tlefile)
sat=[];
return
end
cd(currpath)
tlefile=fullfile(tlepath,tlefile);
end
fp=fopen(tlefile,'r');line=fgetl(fp);i=0;mu=constant('G')*constant('Me');
Pe=24*3600;while sum(line)>0 i=i+1; name{i}=line; line=fgetl(fp); year=line(19:20); day=str2num(line(21:32)); if str2num(year(1))>4 year=['19' year]; else year=['20' year]; end year=str2num(year); epoch(i,:)=datevec(datenum(year,0,day)); line=fgetl(fp); rpd=str2num(line(53:63)); OE(i,1)=(mu*(Pe/rpd/2/pi)^2)^(1/3); OE(i,2)=str2num(['.' line(27:33)]); OE(i,3)=str2num(line(9:16)); OE(i,4)=str2num(line(18:25)); OE(i,5)=str2num(line(35:42)); OE(i,6)=str2num(line(44:51)); line=fgetl(fp);endfclose(fp);
for j=1:i
sat(j).oe=OE(j,:);
sat(j).name=deblank(name{j});
sat(j).epoch=epoch(j,:);
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -