Determine Whether a Queue Is Nonempty

To determine whether a queue is storing any entities, use this technique:

  1. Enable the #n output signal from the queue block. In the block dialog box, on the Statistics tab, select the Number of entities in queue, #n check box.

  2. From the Math Operations library in the Simulink® library set, insert a Sign block into the model. Connect the #n output port of the queue block to the input port of the Sign block.

The Sign block output has values of 0 and 1. A value of 1 indicates that the queue is storing one or more entities. A value of 0 indicates that the queue is not storing any entities.

Was this topic helpful?