timer.set, set timer
Set timer property values.
📝Syntax
set(t, 'PropertyName', PropertyValue, ...)
set(t, values)
t.PropertyName = PropertyValue
📥Input Arguments
Parameter Description
t Timer object or timer object array.
PropertyName Name of a writable timer property.
PropertyValue New value for the property.
values Scalar structure whose fields are timer property names. Read-only fields are ignored.
📄Description

set changes writable timer properties. Writable properties include BusyMode, ErrorFcn, ExecutionMode, Name, ObjectVisibility, Period, StartDelay, StartFcn, StopFcn, Tag, TasksToExecute, TimerFcn, and UserData.

Do not change scheduling properties such as BusyMode, ExecutionMode, Period, or StartDelay while a timer is running.

💡Examples
Configure a timer with property name and value pairs.
t = timer();
set(t, 'Name', 'setExample', ...
  'ExecutionMode', 'fixedSpacing', ...
  'Period', 0.05, ...
  'TasksToExecute', 2, ...
  'TimerFcn', @(src, event) disp(get(src, 'Name')));
start(t);
wait(t);
delete(t);
Set multiple properties from a structure.
t = timer('TimerFcn', @(src, event) disp('done'));
values = struct();
values.Tag = 'batch';
values.StartDelay = 0.1;
set(t, values);
get(t, 'Tag')
delete(t);
🔗See Also
timerget
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub