版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qian_meng/article/details/48413607
这边主要是提供一个处理Timer的工具函数,这个函数用来启动、停止和删除Timer对象
function DealTimer(Type,TimerName)
% 处理Timer工具类
% by qm
% Email:[email protected]
% 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