MATLAB Examples

Temporal Logic Using the EVERY Function

This example shows the advantage of using the EVERY function to call a graphical function when certain events occur. Notice how complicated it becomes when you try to accomplish the same behavior without the use of temporal logic functions.


With Temporal Logic

In the Temporal Logic chart, we specify that every 5 secs (events), we will add one to the local variable 'count'. We then say that every 10 secs, we will call the graphical function, double_counter, which is a function that doubles its input, and give it the value of 'count', Notice that only one state and one graphical function block are needed to accomplish this task when using temporal logic.

Without Temporal Logic

In the Without Temporal Logic chart, we create the same behavior as the Temporal Logic chart. In order to accomplish this, we need to use 4 state blocks and one graphical function block. Also, it becomes much more difficult to follow the transitions and events that take place in the model. Again, the graphical function, double_counter is called using 'count' as the input.