Friday, December 20, 2024

Analogue Clock Using MATLAB

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: Screenshot of the program output
Screenshot of the program output

Analogue clock using MATLAB

The coding is developed using MATLAB version 7.9.0.529 (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.

Program logic

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.

- Advertisement -

Download source code: click here

Commands used

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.

- Advertisement -

Feel interested? Check out other matlab projects.

20 COMMENTS

SHARE YOUR THOUGHTS & COMMENTS

EFY Prime

Unique DIY Projects

Truly Innovative Electronics

Electronics News

Latest DIY Videos

Electronics Components

Electronics Jobs

Calculators For Electronics