Quantcast

Documentation Center

  • Trial Software
  • Product Updates

get

Class: timer

Query property values for timer object

Syntax

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

String enclosed in single quotation marks that specifies a timer property.

Examples

expand all

Display All Properties of Timer

t = timer;
get(t)
       AveragePeriod: NaN
            BusyMode: 'drop'
            ErrorFcn: ''
       ExecutionMode: 'singleShot'
       InstantPeriod: NaN
                Name: 'timer-1'
    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)

Obtain Properties for Array of Timers

Create three timers.

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

Get properties of an array of timers.

V = get([t1,t2,t3])
V = 

3x1 struct array with fields:

    AveragePeriod
    BusyMode
    ErrorFcn
    ExecutionMode
    InstantPeriod
    Name
    ObjectVisibility
    Period
    Running
    StartDelay
    StartFcn
    StopFcn
    Tag
    TasksExecuted
    TasksToExecute
    TimerFcn
    Type
    UserData

Delete the timers from memory.

delete([t1,t2,t3])

Obtain Single Property for Timer

Create a timer and determine if it is running.

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

off

Delete the timer from memory.

delete(t)

Obtain Specified Properties for Array of Timers

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 = 

    'timer-1'    'off'    [1]
    'timer-2'    'off'    [1]
    'timer-3'    'off'    [1]

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

|

Was this topic helpful?