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) ');
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);