Main Content

Find Nonzero Elements in an Array

This example shows how to use the Find block to find nonzero elements in an array. In the following model, the block is configured to output both the one-based linear index and the value of each nonzero element.

ans = 

  Simulink.SimulationOutput:
                   tout: [51x1 double] 

     SimulationMetadata: [1x1 Simulink.SimulationMetadata] 
           ErrorMessage: [0x0 char]