get

Class: timer

Query property values for timer object

Description

example

get(t) queries property values for timer object, t, and displays all property names and current values. t must be a scalar timer object.

example

V = get(t) queries property values for timer object, t and returns a structure, V, where each field name is the name of a property of t and each field contains the value of that property. If t is an M-by-1 vector of timer objects, V is an M-by-1 array of structures.

example

V = get(t,propName) returns the value, V, of the timer object property specified in propName. If propNames is a vector cell array of N property names, and t is a vector of M timer objects, v is an M-by-N cell array of property values.

Input Arguments

t

Object of class timer.

propName

Character vector or string scalar that specifies a timer property name.

Examples

expand all

t = timer;
get(t)
       AveragePeriod: NaN
            BusyMode: 'drop'
            ErrorFcn: ''
       ExecutionMode: 'singleShot'
       InstantPeriod: NaN
                Name: 'timer-2'
    ObjectVisibility: 'on'
              Period: 1
             Running: 'off'
          StartDelay: 0
            StartFcn: ''
             StopFcn: ''
                 Tag: ''
       TasksExecuted: 0
      TasksToExecute: Inf
            TimerFcn: ''
                Type: 'timer'
            UserData: []

Delete the timer from memory.

delete(t)

Create three timers.

t1 = timer;
t2 = timer;
t3 = timer;

Get properties of an array of timers.

V = get([t1,t2,t3])
V=3×18 struct
    BusyMode
    ErrorFcn
    ExecutionMode
    Name
    ObjectVisibility
    Period
    StartDelay
    StartFcn
    StopFcn
    Tag
    TasksToExecute
    TimerFcn
    UserData
    AveragePeriod
    InstantPeriod
    Running
    TasksExecuted
    Type
      ⋮

Delete the timers from memory.

delete([t1,t2,t3])

Create a timer and determine if it is running.

t = timer;
get(t,'Running')
ans = 
'off'

Delete the timer from memory.

delete(t)

Create three timers.

t1 = timer;
t2 = timer;
t3 = timer;

Obtain name, period, and running property values from the array of timers.

V = get([t1,t2,t3],{'Name','Running','Period'})
V=3×3 cell
    {'timer-2'}    {'off'}    {[1]}
    {'timer-3'}    {'off'}    {[1]}
    {'timer-4'}    {'off'}    {[1]}

Delete the timers

delete([t1,t2,t3])

Alternatives

You can also use dot notation can also be used to query timer object properties. For example, t.Running returns the same value as get(t,'Running').

See Also

|

Introduced before R2006a