Code for Working clock plot
%code to display working clock
clear all
close all
clc
l1=1; % minute hand
l2=1.2; % seconds hand % these are the length of the clock hands
l3=0.7; % hour hand
theta1=linspace(90,-360+90,61);% negative sign for clockwise rotation
theta2=linspace(90,-360+90,61);% 360 + 90 because strating is not from 0 but from 90
theta3=linspace(90,-360+90,13); % TOTAL 12 DEVISION ARE THERE BUT 1 AND 13 ARE COUNTED AS SAME THATS WHY 13..
for m=1:(length(theta3)-1) % for hours
Theta3=theta3(m);
for i=1:(length(theta1)-1) % for minutes
Theta1=theta1(i);
for j=1:(length(theta2)-1) % for second
Theta2=theta2(j);
x0=0; % initial values of all hands
y0=0;
x3=l3*cosd(Theta3); % final value of hour hand
y3=l3*sind(Theta3);
x1=l1*cosd(Theta1); % final value of minutes HAND
y1=l1*sind(Theta1);
x2=l2*cosd(Theta2); % final value of second hand
y2=l2*sind(Theta2);
% making coircle for the clock
r=1.23; % RADIUS OF OUR CLOCK
t=linspace(0,360);
x=r*cosd(t); % parametric circle eQuations
y=r*sind(t); % real equations will have included a and b on x and y equations resp.. but as we are ploting the circle
% from origin so their value is zero....
plot([x0,x1],[y0,y1],[x0,x2],[y0,y2],[x0,x3],[y0,y3],x,y,'linewidth',4.5);
axis([-1.5 1.5 -1.5 1.5]); % for representing the plane or graph.......
pause(1) % changing this value wil change the speed of second hand
end
end
end
Vedio demonstration: