Matlab学习——(1)模拟时钟

t=0:pi/20:2*pi;
X=cos(t);
Y=sin(t);

plot(X,Y);
hold on;
axis equal;

linex=[0,1];
liney=[0,0];

linex1=[0,1];
liney1=[0,0];
h=plot(linex,liney);
h1=plot(linex1,liney1);

theta=pi/2;
theta1=pi/2;
count=0;
while true
    theta=theta-pi/300;
    linex(2)=cos(theta);
    liney(2)=sin(theta);
    set(h,'Xdata',linex,'YData',liney);
    count=count+1;
    drawnow;
    if mod(count,60)==0
        theta1=theta1-pi/60;
        linex1(2)=0.5*cos(theta1);
        liney1(2)=0.5*sin(theta1);
        set(h1,'XData',linex1,'YData',liney1);
        drawnow;
    end
end

你可能感兴趣的:(matlab,matlab)