Documentation

Find Nonzero Elements

Find nonzero elements in array

  • Library:
  • 万博1manbetxSimulink /数学操作

描述

TheFind Nonzero Elementsblock locates all nonzero elements of the input signal and returns the linear indices of those elements. If the input is a multidimensional signal, theFind Nonzero Elements块还可以返回非零输入元素的下标。在这两种情况下,您都可以显示具有非零输入值的输出端口。

TheFind Nonzero Elementsblock outputs a variable-size signal. The sample time for any variable-size signal must be discrete. If your model does not already use a fixed-step solver, you may need to select a fixed-step solver in the Configuration Parameters dialog. For more information, seeSolversChoose a Solver.

端口

输入

expand all

输入signal from which the block finds all nonzero elements.

Data Types:single|double|int8|INT16|INT32|uint8|UINT16|uint32|Boolean|固定点

Output

expand all

TheFind Nonzero Elementsblock outputs the indices of nonzero elements as a variable-size signal. You control the data type of the output using the输出数据类型block parameter.

Dependencies

By default, the block outputs linear indices from the first output port. When you change the索引输出格式toSubscripts, the block instead provides the element indices of a two-dimension or larger signal in a subscript form. In this mode, you must specify theNumber of input dimensions, and the block creates a separate output port for each dimension.

Data Types:single|double|int8|INT16|INT32|uint8|UINT16|uint32|Boolean|固定点

查找块可以选择将所有非零元素的值作为可变大小信号输出。

Dependencies

要启用此端口,请选择显示非零输入值的输出端口.

Data Types:single|double|int8|INT16|INT32|uint8|UINT16|uint32|Boolean|固定点

Parameters

expand all

主要的

选择非零输入值索引的输出格式。

  • Selecting线性索引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.

  • SelectingSubscripts提供下标形式的二维或较大信号的元素索引。由于块为每个维度显示一个输出端口,因此此选项要求您指定Number of input dimensions.

Programmatic Use

块参数:IndexOutputFormat
Type:character vector
Values:'Linear indices'|'Subscripts'
Default:'Linear indices'

指定输入信号的尺寸数量为1到32的正整数值。

Dependencies

To enable this parameter, set索引输出格式toSubscripts.

Programmatic Use

块参数:数字插入
Type:character vector
Values:scalar
Default:'1'

将索引模式指定为Zero-based或者One-based.

  • ForZero-based索引,索引0指定输入向量的第一个元素。一个索引1指定第二个元素,依此类推。

  • ForOne-based索引,索引1指定输入向量的第一个元素。一个索引2, specifies the second element, and so on.

Programmatic Use

块参数:IndexMode
Type:character vector
Values:“基于零”|'One-based'
Default:“基于零”

显示或隐藏非零输入值的输出端口。

  • When you clear this check box (离开), the block hides the output port for nonzero input values.

  • When you select this check box (), the block displays the output port for nonzero input values. The additional output port provides values of the nonzero input elements.

Programmatic Use

块参数:ShowOutputPortForNonzeroInputValues
Type:character vector
Values:'on'|'离开'
Default:'离开'

将样本时间指定为-1以外的值。有关更多信息,请参阅Specify Sample Time.

Dependencies

除非明确设置为以外的值,否则该参数不可见-1. To learn more, see块for Which Sample Time Is Not Recommended.

Programmatic Use

块参数:SampleTime
Type:character vector
Values:scalar
Default:'-1'

Data Types

指定输出数据类型。

点击Show data type assistantbuttonto display the数据类型助手, which helps you set the data type attributes. See指定数据类型使用数据泰pe Assistantfor more information.

Programmatic Use

块参数:OutdatatyPest
Type:character vector
Values:'Inherit: Inherit via internal rule'|'int8'|'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32'| 'fixdt(1,16)'| ''
Default:'Inherit: Inherit via internal rule'

块特征

Data Types

double|single|Boolean|基础整数|固定点

Multidimensional Signals

Yes

Variable-Size Signals

Yes

Extended Capabilities

C/C ++代码生成
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
使用固定点Designer™将浮点算法转换为固定点。

在R2010a中引入

这个话题有帮助吗?