Table Of Contents

findnz

Version:
    Last Modified: January 9, 2017

    Returns the indexes of all non-zero elements in a matrix.

    Syntax

    ind = findnz(a)
    ind = findnz(a, n)
    ind = findnz(a, n, direction)
    [i, j] = findnz(a)
    [i, j] = findnz(a, n)
    [i, j] = findnz(a, n, direction)
    [i, j, c] = findnz(a)
    [i, j, c] = findnz(a, n)
    [i, j, c] = findnz(a, n, direction)
    Legacy name: find

    Inputs

    a

    Vector or matrix of any data type.

    n

    Number of matches to return. n is a positive integer. The default is to return all matches.

    direction

    Direction to search for matches. direction is a string, that accepts the following values.

    Name Description
    'first' (default)

    Returns the first n matches.

    'last'

    Returns the last n matches.

    Outputs

    ind

    Linear indexes of all non-zero elements of a. a is considered a long vector a(:) if only one output is required. ind is a row vector if a is a row vector, otherwise ind is a column vector.

    i

    First indexes of all non-zero elements of a. i is a column vector.

    j

    Second indexes of all non-zero elements of a. j is a column vector.

    c

    All non-zero elements of a. c is a column vector.

    A = [1, 2, 3; 0, 0, 0; 0, 2, 3]
    [I, J] = findnz(A)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: Not supported


    Recently Viewed Topics