start
启动计时器
语法
说明
示例
启动计时器
使用 start
启动计时器。
创建并启动一个计时器,该计时器在 StartFcn
回调时显示消息“timer started.”,在 TimerFcn
回调时生成一个随机数。删除该计时器。
t = timer('StartFcn',@(~,~)disp('timer started.'),... 'TimerFcn',@(~,~)disp(rand(1))); start(t) delete(t)
timer started. 0.9706
rand
的输出将会变化。
启动多个计时器
使用 start
开始多个计时器。
创建三个显示 StartFcn
回调的消息的计时器并启动它们。在执行 TimerFcn
回调时计算 pi/4
的正弦、余弦和正切。删除这些计时器。
t1 = timer('StartFcn',@(~,~)disp('t1 started.'),... 'TimerFcn',@(~,~)sin(pi/4)); t2 = timer('StartFcn',@(~,~)disp('t2 started.'),... 'TimerFcn',@(~,~)cos(pi/4)); t3 = timer('StartFcn',@(~,~)disp('t3 started.'),... 'TimerFcn',@(~,~)tan(pi/4)); start([t1 t2 t3]); delete([t1 t2 t3]);
t1 started. t2 started. t3 started.
输入参数
t
— 计时器
计时器 | 计时器数组
要启动的计时器,指定为计时器或计时器数组。
版本历史记录
在 R2006a 之前推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)