function RepT=spanOrbit(long)
% This script runs automatically the Repointing model over the longitude
% vector and plots the results
%
% Example: spanOrbit([20 30 40]);
%
% Author: Ugo Pattacini
model='Repointing';
open(model);
drawnow;
f=@(long)(elpsTime(model,long));
d=size(long);
if d(2)>d(1)
long=long';
end
L=length(long);
RepT=zeros(L,1);
Selector=zeros(L,1);
Manoeuvre=cell(L,1);
str={'Azimuth' 'Elevation'};
for i=1:L
[RepT(i),Selector(i)]=f(long(i));
Manoeuvre{i}=str{Selector(i)+1};
disp(sprintf('Long=%.3f, RepT=%.3fs, Manoeuvre in %s',long(i),RepT(i),Manoeuvre{i}));
drawnow;
end
figure;
plot(long,RepT,'bo-','LineWidth',2);
xlabel('Pass-break Long (towards N) []');
ylabel('Repointing Time [s]');
grid;
RepT={long RepT Manoeuvre};
function [RepT,Selector]=elpsTime(model,long)
set_param(strcat(bdroot,'/Settings'),'sat0',sprintf('[%d %d]',0,long));
[t,x,y]=sim(model,inf);
RepT=y(end,1);
Selector=y(end,2);