Escolar Documentos
Profissional Documentos
Cultura Documentos
USING MATLAB
PROBLEM STATEMENT:
Making a clock in GUI MATLAB
clf
shg
axis square
axis off
x = sin(2*pi*(1:60)/60);
y = cos(2*pi*(1:60)/60);
k = 5:5:60;
line(x,y,'linestyle','none','marker',‘^’,'color','black','markersize',2)
line(x(k),y(k),'linestyle','none','marker','*','color','black','markersize',8)
m = line([0 0],[0,0],'color','blue','linewidth',4);
while get(klose,'value')==0
c = clock;
text(-0.4,-1.2,datestr(datenum(c(1),c(2),c(3))),'fontsize',16)
t = c(5)/60 + c(6)/3600;
k = ceil(c(6));
pause(1.0)
end
close(gcf)
DESCRIPTION OF CODE:
clf -Clears the current figure.
shg-Shows the graph window. shg brings the current figure window forward .
axis- sets the scaling for the x-, y- and z-axes on the current 3-D plot .
Datenum-N = datenum(V) converts one or more date vectors V into serial date
numbers N.
set-set(H,'PropertyName',PropertyValue) sets the value of the
specified property for the graphics object with handle H.
ceil-ceil(X) rounds the elements of X to the nearest integers
towards infinity.
Pause- pause(n) pauses for n seconds before continuing, where n
can also be afraction.
gcf -Get handle to current figure. H = gcf returns the handle of
the current figure. The current figure is the window into which
graphics commands like PLOT,TITLE, SURF, etc. will draw.
So using this code we’ve first created the axis and then plotted the
circle.
Later we’ve given the linestyle of the analog clock. Then we
written a code for hours hand , minutes hand and seconds hand to
display on the clock. We then had given the code to set date and
time from the system that is set on our system.
OUTPUT:
In this way
we can run
the code &
our Analog
Clock gets
displayed…
YOU
ANK
TH