Documentation

Find

Find nonzero elements in array

Library

Math Operations

Description

The Find block locates all nonzero elements of the input signal and returns the linear indices of those elements. If the input is a multidimensional signal, the Find block can also return the subscripts of the nonzero input elements. In both cases, you can show an output port with the nonzero input values.

Data Type Support

The Find block accepts and outputs real values of any numeric data type that Simulink® supports.

For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

The Main pane of the Find block dialog box appears as follows:

The Signal Attributes pane of the Find block dialog appears as follows:

Index output format

Select the output format for the indices of the nonzero input values.

Settings

Default: Linear indices

Linear indices

Provides the element indices of any dimension signal in a vector form. For one dimension (vector) signals, indices correspond to the position of nonzero values within the vector. For signals with more than one dimension, the conversion of subscripts to indices is along the first dimension. You do not need to know the signal dimension of the input signal.

Subscripts

Provides the element indices of a two-dimension or larger signal in a subscript form. Because the block shows an output port for each dimension, this option requires you to know the number of dimensions for the input signal.

Dependencies

Selecting Subscripts from the Index output format list enables the Number of input dimensions parameter.

Command-Line Information

Parameter: IndexOutputFormat
Type: string
Value: Linear indices | Subscripts
Default: Linear indices

Number of input dimensions

Specify the number of dimensions for the input signal.

Settings

Default: 1

Minimum: 1

Maximum: 32

Dependencies

Selecting Subscripts from the Index output format list enables this parameter.

Command-Line Information

Parameter: NumberOfInputDimensions
Type: int
Value: positive integer value
Default: 1

Index mode

Specify the indexing mode.

Settings

Default: Zero-based

Zero-based

An index of 0 specifies the first element of the input vector. An index of 1 specifies the second element, and so on.

One-based

An index of 1specifies the first element of the input vector. An index of 2, specifies the second element , and so on.

Command-Line Information

Parameter: IndexMode
Type: string
Value: Zero-based | One-based
Default: Zero-based

Show output port for nonzero input values

Show or hide the output port for nonzero input values.

Settings

Default: Off

On

Display the output port for nonzero input values. The additional output port provides the values of the nonzero input elements.

Off

Hide the output port for nonzero input values.

Command-Line Information

Parameter: ShowOutputPortForNonzeroInputValues
Type: string
Value: 'on' | 'off'
Default: 'off'

Sample time (-1 for inherited)

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specify Sample Time.

Command-Line Information

Parameter: SampleTime
Type: string
Value: -1 (for inherited)| positive number
Default: -1

Output data type

Specify the output data type.

Settings

Default: Inherit: Inherit via internal rule

Inherit: Inherit via internal rule

Output data type is defined by the target.

int8

Output data type is int8.

uint8

Output data type is uint8.

int16

Output data type is int16.

uint16

Output data type is uint16.

int32

Output data type is int32.

uint32

Output data type is unt32.

fixdt(1,16)

Output data type is fixed point, fixdt(1,16).

<data type expression>

Use a data type object, for example, Simulink.NumericType.

Click the Show data type assistant button to display additional parameters for the Output data type parameter.

Command-Line Information

Parameter: OutDataTypeStr
Type: string
Value: 'Inherit: Inherit via internal rule' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32'| 'fixdt(1,16)'| '<data type expression>'
Default: 'Inherit: Inherit via internal rule'

See Also

Specify Block Output Data Types, Specify Data Types Using Data Type Assistant

Mode

Select the category of data to specify.

Settings

Default: Inherit

Inherit

Inheritance rules for data types. Selecting Inherit enables a second list of the possible values:

  • Inherit via internal rule (Discrete-Time Integrator, Gain, Product, Sum, Switch block default)

Built in

Built-in data types. Selecting Built in enables a second list of the possible values:

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

Fixed point

Fixed-point data types.

Expression

Expressions that evaluate to data types. Selecting Expression enables a second text box, where you can enter the expression.

Dependencies

Clicking the Show data type assistant button enables this parameter.

Selecting Fixed point from the Mode list enables the following parameters:

  • Signed

  • Scaling

  • Word length

See Also

Specify Data Types Using Data Type Assistant

Data type override

Specify data type override mode for this signal.

Settings

Default: Inherit

Inherit

Inherits the data type override setting from its context, that is, from the block, Simulink.Signal object or Stateflow® chart in Simulink that is using the signal.

Off

Ignores the data type override setting of its context and uses the fixed-point data type specified for the signal.

Tip

The ability to turn off data type override for an individual data type provides greater control over the data types in your model when you apply data type override. For example, you can use this option to ensure that data types meet the requirements of downstream blocks regardless of the data type override setting.

Dependency

This parameter appears only when the Mode is Built in or Fixed point.

Signedness

Specify whether the fixed-point data is signed or unsigned.

Settings

Default: Signed

Signed

Specifies the fixed-point data as signed.

Unsigned

Specifies the fixed-point data as unsigned.

Dependency

Selecting Fixed point from the Mode list enables this parameter.

Word length

Specify the bit size of the word that holds the quantized integer.

Settings

Default: 16

Minimum: 0

Maximum: 32

Large word sizes represent large values with greater precision than small word sizes.

Dependency

Selecting Fixed point from the Mode list enables this parameter.

Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

Settings

Default: Integer

Integer

Specifies a binary point location for fixed-point data and sets the fraction length to 0.

The Scaling list has only one item for you to select.

Dependency

Selecting Fixed point from the Mode list enables this parameter.

Characteristics

Direct Feedthrough

Yes

Sample Time

Specified in the Sample time parameter

Scalar Expansion

No

Dimensionalized

Yes

Multidimensionalized

Yes

Zero-Crossing Detection

No

Was this topic helpful?