MATLAB Programming
MATLAB Programming MATLAB Programming
10 Scheduling Program Execution with Timers get(t) AveragePeriod: NaN BusyMode: 'drop' ErrorFcn: '' ExecutionMode: 'singleShot' InstantPeriod: NaN Name: 'timer-4' ObjectVisibility: 'on' Period: 1 Running: 'off' StartDelay: 0 StartFcn: '' StopFcn: '' Tag: '' TasksExecuted: 0 TasksToExecute: Inf TimerFcn: '' Type: 'timer' UserData: [] Setting the Value of Timer Object Properties To set the value of a timer object property, use the set function or subscripted assignment (dot notation). You can also set timer object properties when you create the timer object. For more information, see “Creating Timer Objects” on page 10-5. The following example uses both methods to assign values to timer object properties. The example creates a timer that, once started, displays a message every second until you stop it with the stop command. 1 Create a timer object. t = timer; 2 Assign values to timer object properties using the set function. set(t,'ExecutionMode','fixedRate','BusyMode','drop','Period',1); 3 Assign a value to the timer object TimerFcn property using dot notation. t.TimerFcn = 'disp(''Processing...'')' 10-8
Working with Timer Object Properties 4 Start the timer object. It displays a message at 1-second intervals. start(t) 5 Stop the timer object. stop(t) 6 Delete timer objects after you are done using them. delete(t) Viewing a List of All Settable Properties To view a list of all timer object properties that can have values assigned to them (in contrast to the read-only properties), use the set function, specifying the timer object as the only argument. The display includes the values you can use to set the property if, like the BusyMode property, the property accepts an enumerated list of values. t = timer; set(t) BusyMode: [ {drop} | queue | error ] ErrorFcn: string -or- function handle -or- cell array ExecutionMode: [{singleShot} | fixedSpacing | fixedDelay | fixedRate] Name ObjectVisibility: [ {on} | off ] Period StartDelay StartFcn: string -or- function handle -or- cell array StopFcn: string -or- function handle -or- cell array Tag TasksToExecute TimerFcn: string -or- function handle -or- cell array UserData 10-9
- Page 694 and 695: 9 Classes and Objects q = polynom(q
- Page 696 and 697: 9 Classes and Objects % POLYNOM/DIF
- Page 698 and 699: 9 Classes and Objects Building on O
- Page 700 and 701: 9 Classes and Objects Multiple Inhe
- Page 702 and 703: 9 Classes and Objects Inheritance M
- Page 704 and 705: 9 Classes and Objects a.currentValu
- Page 706 and 707: 9 Classes and Objects error('Asset
- Page 708 and 709: 9 Classes and Objects case 'date' a
- Page 710 and 711: 9 Classes and Objects Note that the
- Page 712 and 713: 9 Classes and Objects For example,
- Page 714 and 715: 9 Classes and Objects The Stock sub
- Page 716 and 717: 9 Classes and Objects case '.' swit
- Page 718 and 719: 9 Classes and Objects Example — T
- Page 720 and 721: 9 Classes and Objects if isa(name,'
- Page 722 and 723: 9 Classes and Objects end if saving
- Page 724 and 725: 9 Classes and Objects Saving and Lo
- Page 726 and 727: 9 Classes and Objects • subsref
- Page 728 and 729: 9 Classes and Objects function n =
- Page 730 and 731: 9 Classes and Objects Object Preced
- Page 732 and 733: 9 Classes and Objects How MATLAB De
- Page 734 and 735: 9 Classes and Objects Private funct
- Page 736 and 737: 9 Classes and Objects 9-76
- Page 738 and 739: 10 Scheduling Program Execution wit
- Page 740 and 741: 10 Scheduling Program Execution wit
- Page 742 and 743: 10 Scheduling Program Execution wit
- Page 746 and 747: 10 Scheduling Program Execution wit
- Page 748 and 749: 10 Scheduling Program Execution wit
- Page 750 and 751: 10 Scheduling Program Execution wit
- Page 752 and 753: 10 Scheduling Program Execution wit
- Page 754 and 755: 10 Scheduling Program Execution wit
- Page 756 and 757: 10 Scheduling Program Execution wit
- Page 758 and 759: 10 Scheduling Program Execution wit
- Page 760 and 761: 10 Scheduling Program Execution wit
- Page 762 and 763: 11 Improving Performance and Memory
- Page 764 and 765: 11 Improving Performance and Memory
- Page 766 and 767: 11 Improving Performance and Memory
- Page 768 and 769: 11 Improving Performance and Memory
- Page 770 and 771: 11 Improving Performance and Memory
- Page 772 and 773: 11 Improving Performance and Memory
- Page 774 and 775: 11 Improving Performance and Memory
- Page 776 and 777: 11 Improving Performance and Memory
- Page 778 and 779: 11 Improving Performance and Memory
- Page 780 and 781: 11 Improving Performance and Memory
- Page 782 and 783: 11 Improving Performance and Memory
- Page 784 and 785: 11 Improving Performance and Memory
- Page 786 and 787: 12 Programming Tips MATLAB Path (p.
- Page 788 and 789: 12 Programming Tips numberOfLines)
- Page 790 and 791: 12 Programming Tips Help This secti
- Page 792 and 793: 12 Programming Tips Topic Name arit
10 Scheduling Program Execution with Timers<br />
get(t)<br />
AveragePeriod: NaN<br />
BusyMode: 'drop'<br />
ErrorFcn: ''<br />
ExecutionMode: 'singleShot'<br />
InstantPeriod: NaN<br />
Name: 'timer-4'<br />
ObjectVisibility: 'on'<br />
Period: 1<br />
Running: 'off'<br />
StartDelay: 0<br />
StartFcn: ''<br />
StopFcn: ''<br />
Tag: ''<br />
TasksExecuted: 0<br />
TasksToExecute: Inf<br />
TimerFcn: ''<br />
Type: 'timer'<br />
UserData: []<br />
Setting the Value of Timer Object Properties<br />
To set the value of a timer object property, use the set function or subscripted<br />
assignment (dot notation). You can also set timer object properties when you<br />
create the timer object. For more information, see “Creating Timer Objects”<br />
on page 10-5.<br />
The following example uses both methods to assign values to timer object<br />
properties. The example creates a timer that, once started, displays a message<br />
every second until you stop it with the stop command.<br />
1 Create a timer object.<br />
t = timer;<br />
2 Assign values to timer object properties using the set function.<br />
set(t,'ExecutionMode','fixedRate','BusyMode','drop','Period',1);<br />
3 Assign a value to the timer object TimerFcn property using dot notation.<br />
t.TimerFcn = 'disp(''Processing...'')'<br />
10-8