Class:t一世mer

设置计时器对象的属性值

描述

例子

放(t显示计时器对象的所有可配置属性的属性名称及其可能的值t

例子

道具结构= set(treturns the values in a结构

例子

放(t,,,,Name)displays the possible values for the specified property,Name,计时器对象,t

例子

propcell = set(t,,,,Name)returns the values in a cell.

例子

放(t,,,,名称,价值设置由一个或多个指定的属性名称,价值配对参数。t可以是单个计时器对象或计时器对象的向量,在这种情况下配置所有计时器对象的属性值,t

例子

放(t,,,,s配置属性t,在中指定的值s, 在哪里s是一个字段名称为对象属性名称的结构。

例子

放(t,,,,PN,PV配置字符向量的单元格数组中指定的属性,PN,到单元数组中的相应值PV,对于计时器对象t

输入参数

t

课堂的对象t一世mer

s

字段名称的结构t一世mer属性名称。

PN,PV

字符向量的细胞阵列,PN,以及相应的值的单元格数,PV。细胞阵列PNmust be a 1-by-N or N-by-1 array. Ift一世san array of timer objects,PV可以是m-n细胞阵列,其中m等于tand N is equal to the length ofPN。在这种情况下,每个计时器对象都会使用不同的值集,用于包含的属性名称列表PN

名称值对参数

指定可选的逗号分隔对名称,价值参数。Name是参数名称和Value一世sthe corresponding value.Name必须出现在引号中。您可以按任何顺序指定几个名称和值对参数NAME1,Value1,...,Namen,Valuen

“ busymode'

字符向量或字符串标量表示计时器必须执行时采取的动作TimerFcn在完成之前执行之前TimerFcn。什么时候Running='on',,,,busymode仅阅读。This table summarizes the busy modes.

busymode

行为如果队列为空

行为如果队列不为空

Notes

'降低'

将任务添加到队列

丢弃任务

可能的跳过TimerFcn呼叫

'错误'

将任务添加到队列

完成任务;抛出错误ERRORFCN;停止st一世mer

完成执行队列任务后停止计时器

'queue'

将任务添加到队列

Waits for queue to clear, and then enters task in queue

调整时期在执行队列中管理任务的属性

处理计时器排队冲突了解更多信息。

默认:'降低'

'errorfcn'

字符向量,字符串标量,函数句柄或单元格数组定义发生错误时计时器执行的函数。如果有错误,则该函数执行,然后调用StopFCN

  • 如果您使用字符向量或字符串标量指定此属性,则在MATLAB时®执行回调,它评估了字符向量中包含的MATLAB代码。

  • If you specify this property using a function handle, when MATLAB executes the callback it passes thet一世mer对象和回调函数的事件结构。事件结构包含事件类型类型field and the time of the event in the数据field.

  • 如果您的回调功能除了接受参数t一世mer对象和事件数据,将此属性指定为包含函数句柄和其他参数的单元格数组。

有关更多信息,请参阅计时器回调函数

'ExecutionMode'

字符向量或字符串标量定义如何t一世mer对象计划计时器事件。什么时候Running='on',,,,ExecutionMode仅阅读。This table summarizes the execution modes.

执行模式

Time时期起点

's一世ngleShot'

在这种模式下,timer callback function is only executed once. Therefore, the时期财产无效。这是默认执行模式。

'固定利率'

starts immediately after the timer callback function is added to the MATLAB execution queue

'fixedDelay'

starts when the timer function callback restarts execution after a time lag due to delays in the MATLAB execution queue

'fixedSpacing'

starts when the timer callback function finishes executing.

  • 's一世ngleShot'是单个执行模式t一世mer类,是默认值。

  • 'fixedDelay',,,,'固定利率',,,,and'fixedSpacing'are the three supported multiexecution modes. These modes define the starting point of the时期财产。这时期property specifies the amount of time between executions, which remains the same. Only the point at which execution begins is different.

默认:'s一世ngleShot'

'姓名'

字符向量或字符串标量代表t一世mer姓名。

默认:'t一世mer-一世', 在哪里一世一世sa number indicating the一世计时对象创建了此会话。重置一世到1,执行clear classescommand.

“对象可视化”

字符向量或字符串标量,可能的值'上'or'离开',,,,that provides a way for you to discourage end-user access to the timer objects your application creates. The计时function does not return an object whoseObjectVisibility属性设置为'离开'。Objects that are not visible are still valid. To retrieve a list of all the timer objects in memory, including the invisible ones, use the计时all功能。

默认:'上'

'时期'

大于0.001的数字,指定在执行之间的延迟数秒TimerFcn。For the timer to use时期,,,,you must setExecutionModeandTaskStoexecuteto schedule multiple timer object callback events.

默认:1.0

'startDelay'

数字大于或等于0,指定计时器开始和指定函数的第一个执行之间指定延迟的数字TimerFcn。什么时候running ='on',,,,startDelay仅阅读。

默认:0

'startFcn'

字符向量,字符串标量,函数句柄或单元格数组定义计时器启动时执行的函数。

  • 如果您使用字符向量或字符串标量指定此属性,则在MATLAB时执行回调,它评估了字符向量中包含的MATLAB代码。

  • If you specify this property using a function handle, when MATLAB executes the callback it passes thet一世mer对象和回调函数的事件结构。事件结构包含事件类型类型field and the time of the event in the数据field.

  • 如果您的回调功能除了接受参数t一世mer对象和事件数据,将此属性指定为包含函数句柄和其他参数的单元格数组。

有关更多信息,请参阅计时器回调函数

'stopfcn'

字符向量,字符串标量,函数句柄或单元格数组定义计时器停止时执行的函数。

  • 如果您使用字符向量或字符串标量指定此属性,则在MATLAB时执行回调,它评估了字符向量中包含的MATLAB代码。

  • If you specify this property using a function handle, when MATLAB executes the callback it passes thet一世mer对象和回调函数的事件结构。事件结构包含事件类型类型field and the time of the event in the数据field.

  • 如果您的回调功能除了接受参数t一世mer对象和事件数据,将此属性指定为包含函数句柄和其他参数的单元格数组。

有关更多信息,请参阅计时器回调函数

这t一世mer stops when

  • 你打电话给计时器停止方法。

  • 计时器完成执行TimerFcn。换句话说,价值TasksExecutedreaches the limit set byTaskStoexecute

  • 发生错误。这ERRORFCN回调首先称为StopFCN打回来。

您可以使用StopFCNto define clean up actions, such as deleting the timer object from memory.

'标签'

Character vector or string scalar that represents a label for the object.

'TaskStoexecute'

Number greater than 0, indicating the number of times the timer object is to execute theTimerFcn打回来。使用TaskStoexecute设置执行次数的属性。使用TaskStoexecute,,,,you must setExecutionMode安排多个计时器回调事件。

默认:inf

'TimerFcn'

字符向量,字符串标量,函数句柄或单元格数组定义计时器回调函数。您必须在启动计时器之前定义此属性。

  • 如果您使用字符向量或字符串标量指定此属性,则在MATLAB时执行回调,它评估了字符向量中包含的MATLAB代码。

  • If you specify this property using a function handle, when MATLAB executes the callback it passes thet一世mer对象和回调函数的事件结构。事件结构包含事件类型类型field and the time of the event in the数据field.

  • 如果您的回调功能除了接受参数t一世mer对象和事件数据,将此属性指定为包含函数句柄和其他参数的单元格数组。

有关更多信息,请参阅计时器回调函数

'用户数据'

要添加到对象的数据的通用字段。

Output Arguments

道具结构

可配置的属性t,作为结构返回。字段名称道具结构are the property names oft,,,,and the associated values of道具结构are cell arrays of the possible property values. If the property intdoes not have a finite set of possible values, the property value in道具结构是一个空的单元格数组。

propcell

Possible values of a given property name, returned as cell array of character vectors. If the property does not have a finite set of possible values,returns an empty cell array.

例子

展开全部

Instantiate a timer object and call the方法。

t =计时器;设置(t)
Name: {} Tag: {} ObjectVisibility: {2x1 cell} TasksToExecute: {} StartFcn: {} StopFcn: {} ErrorFcn: {} TimerFcn: {} StartDelay: {} Period: {} BusyMode: {3x1 cell} ExecutionMode: {4x1 cell} UserData: {}

some of the timer properties, such asRunning,不显示它们是因为它们仅读取。

使用method to output a structure.

out = set(t)
out =带有字段的结构:Name: {} Tag: {} ObjectVisibility: {2x1 cell} TasksToExecute: {} StartFcn: {} StopFcn: {} ErrorFcn: {} TimerFcn: {} StartDelay: {} Period: {} BusyMode: {3x1 cell} ExecutionMode: {4x1 cell} UserData: {}

从内存中删除计时器对象。

删除(t)

实例化计时器对象,并显示busymode财产。

t =计时器;设置(t,“ busymode'
3x1单元格数组{'drop'} {'queue'} {'error'}

这output shows the three possible values forbusymode。默认值,drop,,,,一世s一世ndicated by curly braces.

Display the possible values forERRORFCN

设置(t,'errorfcn'
0x0 empty cell array

显示可能值的描述,因为ERRORFCN没有可能的值列表。

Output the possible property values.

out1 = set(t,“ busymode'
out1 =3x1单元{'drop' } {'queue'} {'error'}
out2 = set(t,'errorfcn'
out2 = 0x0空单元格数组

尽管设置(t,'ERRORFCN')显示可能的值的描述,out2 = set(t,'errorfcn')返回一个空单元。

从内存中删除计时器。

删除(t)

实例化计时器对象并使对象不可见。显示对象的可见性并删除对象。

t =计时器;设置(t,“对象可视化”,,,,'离开')获取(t,“对象可视化”
ans ='off'
删除(t)

Construct a structure to modify several timer object properties.

s.busymode ='queue';S.ExecutionMode ='fixedDelay';S.Objectivisibility ='离开'
s =带有字段的结构:busymode:'queue'executionMode:'fixedDelay'对象效果:'Off'

Create a timer, display the properties ins,修改计时器,显示属性的新值,然后删除计时器。

t =计时器;获取(t,{“ busymode',,,,'ExecutionMode',,,,“对象可视化”})
ans =1×3 cell array{[drop]} {'singleshot'} {'on'}
set(t,s)get(t,{“ busymode',,,,'ExecutionMode',,,,“对象可视化”})
ans =1×3 cell array{[queue]} {'fixedDelay'} {'off'}
删除(t)

Create a cell array of properties to modify, and a cell array of the values of the corresponding properties. Instantiate a timer, and display the initial values of the properties in the property name cell array,Namearr

namearr = {“ busymode',,,,'ExecutionMode',,,,'时期'};valarr = {'queue',,,,'fixedDelay',3};t =计时器;获取(t,namearr)
ans =1×3 cell array{[drop]} {'singleshot'} {[1]}

修改计时器对象并显示新的属性值。删除计时器。

set(t,namearr,valarr)get(t,namearr)
ans =1×3 cell array{[queue]} {'fixeddelay'} {[3]}
删除(t)

Instantiate an array of three timers. Create a new property name cell array to modify thebusymode,,,,ExecutionMode,,,,andUserData特性。显示每个计时器的属性的初始值。

tarr = [计时器计时器];namearr = {“ busymode',,,,'ExecutionMode',,,,'用户数据'};获取(塔尔(Tarr),纳米尔(Namearr))
ans =3×3 cell array{[drop]} {'singleShot'} {0x0 double} {[drop]} {'singleShot'} {0x0 double} {[[drop]} {'singleshot'} {0x0 double double}

在每个计时器中为每个属性分配一个不同的值。创建一个包含新值的单元格数组。每一行指示相应计时器中属性的值。

valarr = {'queue',,,,'fixedDelay',3;。。。'错误',,,,'fixedSpacing',,,,42;。。。'降低',,,,'固定利率',,,,'hello'};

修改计时器对象属性并显示更新的值。

Set(Tarr,Namearr,Valarr)Get(Tarr,Namearr)
ans =3×3 cell array{[queue]} {'fixedDelay' } {[ 3]} {[error]} {'fixedSpacing'} {[ 42]} {[drop ]} {'fixedRate' } {'hello'}

Delete the timers from memory.

删除(Tarr)

备择方案

您还可以使用点符号来设置计时器对象属性。例如,t.ObjectVisibility ='OFF'将属性设置为与设置(t,'对象可视性',“ off”)

也可以看看

|

Introduced before R2006a