我目前的程序如下:

function varargout = naozhong(varargin)

% NAOZHONG M-file for naozhong.fig

%      NAOZHONG, by itself, creates a new NAOZHONG or raises the existing

%      singleton*.

%

%      H = NAOZHONG returns the handle to a new NAOZHONG or the handle to

%      the existing singleton*.

%

%      NAOZHONG('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in NAOZHONG.M with the given input arguments.

%

%      NAOZHONG('Property','Value',...) creates a new NAOZHONG or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before naozhong_OpeningFcn gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to naozhong_OpeningFcn via varargin.

%

%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one

%      instance to run (singleton)".

%

% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help naozhong

% Last Modified by GUIDE v2.5 30-Aug-2009 20:19:19

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @naozhong_OpeningFcn, ...

'gui_OutputFcn',  @naozhong_OutputFcn, ...

'gui_LayoutFcn',  [] , ...

'gui_Callback',   []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

% End initialization code - DO NOT EDIT

% --- Executes just before naozhong is made visible.

function naozhong_OpeningFcn(hObject, eventdata, handles, varargin)

% This function has no output args, see OutputFcn.

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% varargin   command line arguments to naozhong (see VARARGIN)

% Choose default command line output for naozhong

% UIWAIT makes naozhong wait for user response (see UIRESUME)

% uiwait(handles.figure1);

A=linspace(0,6.3,1000);

x1=8*cos(A);

y1=8*sin(A);

x2=7*cos(A);

y2=7*sin(A);

plot(x1,y1,'b','linewidth',1.4)     %画时钟外圆

hold on

plot(x2,y2,'b','linewidth',3.5)     %画时钟内圆

fill(0.4*cos(A),0.4*sin(A),'r');    %画圆心

axis off

axis([-10 10 -10 10])               %可以使得axis内的图形等比例放大缩小

axis equal                          %使得等轴

title(date,'fontsize',14,'fontweight','bold')                %给定标题名

for k=1:12;

xk=9*cos(-2*pi/12*k+pi/2);

yk=9*sin(-2*pi/12*k+pi/2);

plot([xk/9*8 xk/9*7],[yk/9*8 yk/9*7],'color',[0.3 0.8 0.9])  %该句plot([x1 x2],[y1 y2])可以实现在点[x1 y1]和[x2 y2]之间划线,也就是指向数字的短线

h=text(xk,yk,num2str(k),'fontsize',12,'color',...            %标1,2,3,...12等数字

[0.9 0.3 0.8],'HorizontalAlignment','center');

end

set(handles.edit1,'string',date)

axes(handles.axes1);

htimer=timer('ExecutionMode','fixedRate' ,'TimerFcn',{@TimeUpdate,handles},'Period',1);

start(htimer);

set(hObject,'doublebuffer','on');

% set(hObject, 'DeleteFcn', {@DeleteFcn, htimer}); %设置窗口销毁时的回调函数

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

function TimeUpdate(hObject,eventdata,handles) %定时器回调函数

ti=clock;

% axes(handles.axes1);

th=-(ti(4)+ti(5)/60+ti(6)/3600)/12*2*pi+pi/2;       %时针当前的角度

xh3=3.0*cos(th);

yh3=3.0*sin(th);                                    %时针末端的点的位置

hh=plot([0  xh3],[0  yh3],'g');                     %如果不是线,而是一个方形指针,则将plot替换为fill即可

tm=-(ti(5)+ti(6)/60)/60*2*pi+pi/2;

xm3=6.0*cos(tm);

ym3=6.0*sin(tm);

hm=plot([0 xm3],[0 ym3],'r');

ts=-(ti(6))/60*2*pi+pi/2;

hs=plot([0 7*cos(ts)],[0 7*sin(ts)],'color','y','linewidth',2);

drawnow;

guidata(hObject, handles);

%

% function DeleteFcn(hObject, eventdata,htimer)          % 窗口关闭的响应函数-停止计时器

%    stop(htimer);

%    delete(htimer); %销毁定时器

%    clear all;

% --- Outputs from this function are returned to the command line.

function varargout = naozhong_OutputFcn(hObject, eventdata, handles)

% varargout  cell array for returning output args (see VARARGOUT);

% hObject    handle to figure

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure

varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)

% hObject    handle to edit1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text

%        str2double(get(hObject,'String')) returns contents of edit1 as a double

% --- Executes during object creation, after setting all properties.

function edit1_CreateFcn(hObject, eventdata, handles)

% hObject    handle to edit1 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.

%       See ISPC and COMPUTER.

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

每次指针都不动的,是怎么回事啊?

matlab的gui倒计时,GUI设计时钟程序中的计时器建立相关推荐

  1. 微信小程序界面设计小程序中的WXSS(css)选择器课程-伪类-:focus 伪类

    小程序中的WXSS(css)选择器课程-伪类-:focus 伪类 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/hua ...

  2. 微信小程序界面设计小程序中的WXSS(css)选择器课程-伪类-:checked 伪类(不支持)

    小程序中的WXSS(css)选择器课程-伪类-:checked 伪类(不支持) 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/to ...

  3. 微信小程序界面设计小程序中的WXSS(css)选择器课程-::before伪元素

    小程序中的WXSS(css)选择器课程-::before伪元素 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/huan ...

  4. 微信小程序界面设计小程序中的WXSS(css)选择器课程-伪类-:nth-child() 伪类

    小程序中的WXSS(css)选择器课程-伪类-:nth-child() 伪类 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/top ...

  5. 微信小程序界面设计小程序中的WXSS(css)选择器课程-伪类-:nth-last-child伪类

    小程序中的WXSS(css)选择器课程-伪类-:nth-last-child伪类 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/t ...

  6. 微信小程序界面设计小程序中CSS3样式精通课程-渐变Gradients-线性渐变Linear Gradients

    线性渐变Linear Gradients 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/huangjuhua 通用语法 ...

  7. 微信小程序界面设计小程序中CSS3样式精通课程-渐变Gradients-使用透明度(transparent)

    渐变Gradients-使用透明度(transparent) 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/huang ...

  8. 微信小程序界面设计小程序中的WXSS(css)选择器课程-子元素选择器

    小程序中的WXSS(css)选择器课程-子元素选择器 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/huangjuhu ...

  9. 微信小程序界面设计小程序中CSS3样式精通课程-边框-box-shadow 盒阴影

    边框-box-shadow 盒阴影 微信小程序交流群:111733917 | 微信小程序从0基础到就业的课程:https://edu.csdn.net/topic/huangjuhua 通用语法 浏览 ...

最新文章

  1. DeepMind 综述深度强化学习:智能体和人类相似度竟然如此高!
  2. linux 内核网络协议栈
  3. 升级Firefox8后watir-webdriver出现错误“unable to obtain stable firefox connection in 60 seconds”...
  4. git分支/标签操作
  5. [20190530]oracle Audit文件管理.txt
  6. Spring框架----IOC的概念和作用之工厂模式
  7. 用VC打开位图程序[转]
  8. 【COGS2652】—天文密葬法(分数规划+长链剖分)
  9. block compressed sparse row (BSR) matrix format
  10. vscode之parcel清空dist目录
  11. Windows网络编程笔记5 -- 其他套接字
  12. PPT到WORD的组合图片复制
  13. siri中文语音助理_智能语音应用在哪些场景?
  14. 什么叫UG编程?UG编程是干什么的?
  15. ubuntu安装anaconda3+cuda11.2+cuDNN+pytorch1.7
  16. Elasticsearch7.x搜索实战
  17. CUDA-Pinned Host Memory
  18. RSA加密及AES对称加密代码实现
  19. 关于Android 抓包 与 反抓包
  20. 用matlab画玫瑰花函数,网上收到的用matlab画玫瑰花的代码怎么不行啊,报告错误,求大神...

热门文章

  1. java.lang.NullPointerException: Attempt to invoke virtual method ‘android.text.Editable android.widg
  2. 响铃:智能小程序瞄准民生,发红包之外百度App的春节谋局
  3. 新笔记本无法激活Office解决办法
  4. 拼多多怎么提高人气|成都盛天海
  5. pr同时导出多个片段
  6. mysql blob 字段_mysql BLOB字段类型用法介绍
  7. 黑马MYSQL课程的基础语法笔记
  8. 快速说唱教学第五期:三分钟教你如何改善自己的音色?
  9. 非主流就业破解就业困境
  10. 非关系型——Redis基础