Matlab处理Timer工具函数
这边主要是提供一个处理Timer的工具函数,这个函数用来启动、停止和删除Timer对象1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52function DealTimer(Type,TimerName)
% 处理Timer工具类
% by qm
% Email:305638715@qq.com
% 2015/09/09
% Type : 动作类型 1 :启动Timer 2 : 停止Timer 3:删除Timer
%% 输入输出预处理
if nargin < 1 || isempty(Type)
Type = 3;
end
if nargin < 2
TimerName = '';
end
if 1 == Type
if ~isempty(TimerName)
ts=timerfind('Name',TimerName);
else
ts=timerfind;
end
if length(ts)>0
start(ts);
end
end
if 2 == Type
if ~isempty(TimerName)
ts=timerfind('Name',TimerName);
else
ts=timerfind;
end
if length(ts)>0
stop(ts);
end
end
if 3 == Type
if ~isempty(TimerName)
ts=timerfind('Name',TimerName);
else
ts=timerfind;
end
if length(ts)>0
stop(ts);
delete(ts);
end
end