NASA might get a fancy digital-count display and retire the analogue clock from Apollo era but the passion for the analogue clock does not end. An analogue clock has moving hands, where the smaller one is the hours hand and travels 30° in one hour, and the longer one is the minutes hand and travels 360° in an hour. The seconds hand rotates with a step of 6°. Here we look to design an analogue clock using MATLAB.
Analogue clock using MATLAB
The coding is developed using MATLAB version 126.96.36.1999 (or R2009b). MATLAB has a good collection of graphics commands for plotting and analysing complex signals. The built-in functions reduce the size of the program and provide the desired output.
Circle with a radius of 10 units is drawn. Hours are marked from 1 to 12, 30° apart. System time such as your PC’s is read by the command. According to the current time of your PC, the hours, minutes and seconds hands are displayed.
Download source code: click here
The figure shows the screenshot of the program output. Commands used in the program for the analogue clock display are given below:
clock( ). This command extracts date, year and current time from the real-time system.
pause ( ). It provides the required time delay in seconds.
clc( ). It clears the command window.
clear( ). It clears all variables.
textxy ( ). This command prints the text in the specified location, which is mentioned as x and y coordinates.
numtostr( ). It converts a number to string data type.
Feel interested? Check out other matlab projects.