help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Astro: Coordinate conversion


From: Isak Delberth Davids
Subject: Astro: Coordinate conversion
Date: Thu, 9 Dec 2010 17:17:16 +0200

Hi all,

The code below converts a set of three time values (h,min,secs), entered by a user, into a single decimal degree value. This essentially being the coordinate conversion in astronomy.

My code does the job, but I am sure someone can help me do it shorter, faster and therefore smarter:

%% Octave script to convert the right ascension (RA) and the declination (DEC) of a
%% celestial position from hours:minutes:seconds format into decimal degrees.
%% Compare result with: https://www.swift.psu.edu/secure/toop/convert.htm

%% The following is the convention:
%% 1 h = 15 deg
%% 60 min = 1 h = 15 deg
%% 60 sec = 1 min = (15/60) deg, therefore 1 sec = (15/3600) deg

RA = zeros(3,1)';
RA(1) = input('Please enter the hours of the RA(1) ');
RA(2) = input('Please enter the minutes of the RA(2) ');
RA(3) = input('and finally please enter the seconds of the RA(3) ');

RA_deg = RA(1)*15 + RA(2)*(15/60) + RA(3)*(15/3600);

computerTime = toc; % turn of the timer
fprintf(stderr, '\n Your right ascension is %f degrees. This code has a terrible structure, in fact it took %f seconds of your time --- improve it! \n',RA_deg, computerTime);

       Cheers,
                   Isak


* * * * * * * * * * * * * * *
*  Isak Delbert Davids *
*  +264-81-33 049 33  *
*  +264-61-206 3789   *
*    Namibia, Afrika     *
* * * * * * * * * * * * * * *


reply via email to

[Prev in Thread] Current Thread [Next in Thread]