satsort.m

来自「航天工程工具箱」· M 代码 · 共 41 行

M
41
字号
function [ssat,i]=satsort(sat,el,d)
%SATSORT  Sort satellite structure array.
%   [SSAT,I] = SATSORT(SAT[,EL[,D]]) sorts the satellite structure
%   SAT with element EL in either ascending order D>0 (default) or
%   descending order D<0. The element number represents the following:
%
%      EL = 1 : a [m]          : semi-major axis (default)
%      EL = 2 : e []           : eccentricity
%      EL = 3 : i [deg]        : inclination
%      EL = 4 : W [deg]        : longitude of the ascending node
%      EL = 5 : w [deg]        : argument of periapsis
%      EL = 6 : M [deg]        : mean anomaly at epoch
%      EL = 7 : epoch [YMDhms] : timepoint for M
%      EL = 8 : name [string]  : name of satellite
%
%   See also ORB2CART, SORTROWS.

% Copyright (c) 2003-06-09, B. Rasmus Anthin.

if nargin<2, el=1;end
if nargin<3, d=1;end
for i=1:length(sat)
   oe(i,:)=sat(i).oe;
   epoch(i,:)=sat(i).epoch;
   name{i}=sat(i).name;
end
name=char(name);
if any(el==(1:6))
   [foo,i]=sortrows(oe,el);
elseif el==7
   [foo,i]=sortrows(epoch);
elseif el==8
   [foo,i]=sortrows(name);
else
   error('Invalid satellite structure element.')
end
ssat=sat(i);
if d<0
   i=flipud(i);
   ssat=sat(i);
end

⌨️ 快捷键说明

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