Matlab处理Timer工具函数

这边主要是提供一个处理Timer的工具函数,这个函数用来启动、中止和删除Timer对象markdown

function 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

版权声明:本文为博主原创文章,未经博主容许不得转载。函数

相关文章
相关标签/搜索