matlab gui axes 动画,如何在GUI的AXES中利用定时器实现动画

求教如何在GUI中的AXES中利用定时器制作动画?

下面的代码只能显示初值点 无法实现动画 不知道为什么?

另外AXES的坐标轴怎么样才能固定住?

代码如下

function varargout = drawtest(varargin)

gui_Singleton = 1;

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

'gui_Singleton',  gui_Singleton, ...

'gui_OpeningFcn', @drawtest_OpeningFcn, ...

'gui_OutputFcn',  @drawtest_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 drawtest is made visible.

function drawtest_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 drawtest (see VARARGIN)

% Choose default command line output for drawtest

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

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

% uiwait(handles.figure1);

NowTime1=clock;

global begintime

begintime=NowTime1(4)+NowTime1(5)+NowTime1(6);

global x

x=100;

global y

y=100;

handles.timer = timer('Period',0.05,'ExecutionMode','FixedRate','TimerFcn',{@PlotUpdate,handles});

start(handles.timer);

set(gcf, 'DeleteFcn', {@DeleteFcn, handles.timer});

function PlotUpdate(obj,events,handles)

global begintime

global x

global y

NowTime=clock;

plottime=NowTime(4)+NowTime(5)+NowTime(6)-begintime;

handles.h=plot(x,y,'.');

set(handles.h,'parent',handles.DH);

set(handles.h,'EraseMode','none','MarkerSize',21)

drawnow

x=100+100*cos(plottime);

y=100+150*sin(plottime);

set(handles.h,'XDate',x,'YDate',y);

function DeleteFcn(hObject, eventdata, t)          %停止计时器

stop(t);

delete(t); %销毁定时器

clear all;

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

function varargout = drawtest_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;

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

function DH_CreateFcn(hObject, eventdata, handles)

% hObject    handle to DH (see GCBO)

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

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

% Hint: place code in OpeningFcn to populate DH

set(hObject,'XLim',[0 1440],'YLim',[0 900]);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值