% moonpos_examples calculates moon position examples.
%******************************************************************************
%
% MATLAB (R) is a trademark of The Mathworks (R) Corporation
%
% Script: moonpos_examples.m
% Programmer: James Tursa
% Version: 1.1
% Date: April 7, 2009
% Copyright: (c) 2009 by James Tursa, All Rights Reserved
%
% This code uses the BSD License:
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions are
% met:
%
% * Redistributions of source code must retain the above copyright
% notice, this list of conditions and the following disclaimer.
% * Redistributions in binary form must reproduce the above copyright
% notice, this list of conditions and the following disclaimer in
% the documentation and/or other materials provided with the distribution
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
% POSSIBILITY OF SUCH DAMAGE.
%
%******************************************************************************
disp(' ')
disp('This script contains all the examples from moonpos help')
disp(' ')
disp('format long')
format long
disp(' ')
disp('The example on pages 312-313 of the book')
disp('x = moonpos(2448724.5,''jd'')')
x = moonpos(2448724.5,'jd')
disp('Request right ascension in hms and declination in dms')
disp('x = moonpos(2448724.5,''jd'',''hms'',''dms'')')
x = moonpos(2448724.5,'jd','hms','dms')
disp('Request only x,y,z output in km')
disp('x = moonpos(2448724.5,''jd'',''xyz'')')
x = moonpos(2448724.5,'jd','xyz')
disp('Request x,y,z output in feet instead km')
disp('x = moonpos(2448724.5,''jd'',''xyz'',''feet'')')
x = moonpos(2448724.5,'jd','xyz','feet')
disp('Request both ra,dec,delta and x,y,z output, with angles in degrees and')
disp('distances in meters')
disp('x = moonpos(2448724.5,''jd'',''radec'',''deg'',''xyz'',''m'')')
x = moonpos(2448724.5,'jd','radec','deg','xyz','m')
disp('Request both ra,dec,delta and x,y,z output, with angles in degrees and')
disp('distances in meters, but this time list the x,y,z first')
disp('x = moonpos(2448724.5,''jd'',''xyz'',''radec'',''deg'',''m'')')
x = moonpos(2448724.5,'jd','xyz','radec','deg','m')
disp('Request position for a string date, with right ascension output in')
disp('hours, minutes, seconds, and declination output in degrees, minutes,')
disp('seconds. Note that we don''t have to specify a time format with this')
disp('example since the result of the datenum function (called in the')
disp('background) is a Serial Date Number, which is the default for moonpos.')
disp('x = moonpos(''01-Jan-2000'',''hms'',''dms'')')
x = moonpos('01-Jan-2000','hms','dms')
disp('Plot the radial distance of the moon for the year 2009')
disp('t = datenum(''01-Jan-2009''):datenum(''31-Dec-2009'');')
disp('x = moonpos(t);')
disp('plot(t,x(:,3));')
disp('title(''2009 Moon Radial Distance from Earth'');')
disp('ylabel(''km'');')
disp('dateaxis(''x'',12);')
t = datenum('01-Jan-2009'):datenum('31-Dec-2009');
x = moonpos(t);
plot(t,x(:,3));
title('2009 Moon Radial Distance from Earth');
ylabel('km');
dateaxis('x',12);