Code covered by the BSD License  

Highlights from
A MATLAB Script for Predicting Lunar Occultations

A MATLAB Script for Predicting Lunar Occultations

by

 

07 Dec 2012 (Updated )

Predict the local circumstances of lunar occultations of a planet or star.

readstar(filename)
function [fid, sname, ram, decm, pmra, pmdec, parlax, radvel] = readstar(filename) 

% read star data file

% required by star*.m

% input

%  filename = name of star data file

% output

%  sname  = star name
%  ram    = J2000 right ascension (hours)
%  decm   = J2000 declination (degrees)
%  pmra   = J2000 proper motion in right ascension
%           (seconds/Julian century)
%  pmdec  = J2000 proper motion in declination
%           (arcseconds/Julian century)
%  parlax = parallax (arcseconds)
%  radvel = radial velocity (kilometers/second)
%  fid    = file id

% Celestial Computing with MATLAB

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% open data file

fid = fopen(filename, 'r');

% check for file open error

if (fid == -1)
   clc; home;
   fprintf('\n\n  error: cannot find this file!!');
   keycheck;
   return;
end

% read 20 lines of data file

for i = 1:1:20
   cline = fgetl(fid);
   switch i
   case 2
      sname = cline;
   case 5
      ram = str2num(cline);
   case 8
      decm = str2num(cline);
   case 11
      pmra = str2num(cline);
   case 14
      pmdec = str2num(cline);
   case 17
      parlax = str2num(cline);
   case 20
      radvel = str2num(cline);
   end
end

status = fclose(fid);
          

Contact us