GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • » Octave core
  • » by package
  • » alphabetical

This view

  • Original page
  • New address

GeezerVison is showing octave.sourceforge.io — Function Reference: find

Octave-Forge - Extra packages for GNU Octave
Home · Packages · Developers · Documentation · FAQ · Bugs · Mailing Lists · Links · Code

Navigation

Operators and Keywords

Function List:

  • » Octave core
  • » by package
  • » alphabetical

C++ API

: idx = find (x)
: idx = find (x, n)
: idx = find (x, n, direction)
: [i, j] = find (…)
: [i, j, v] = find (…)

Return a vector of indices of nonzero elements of a matrix, as a row if x is a row vector or as a column otherwise.

To obtain a single index for each matrix element, Octave pretends that the columns of a matrix form one long vector (like Fortran arrays are stored). For example:

find (eye (2))
 ⇒ [ 1; 4 ]

If two inputs are given, n indicates the maximum number of elements to find from the beginning of the matrix or vector.

If three inputs are given, direction should be one of "first" or "last", requesting only the first or last n indices, respectively. However, the indices are always returned in ascending order.

If two outputs are requested, find returns the row and column indices of nonzero elements of a matrix. For example:

[i, j] = find (2 * eye (2))
   ⇒ i = [ 1; 2 ]
   ⇒ j = [ 1; 2 ]

If three outputs are requested, find also returns a vector containing the nonzero values. For example:

[i, j, v] = find (3 * eye (2))
      ⇒ i = [ 1; 2 ]
      ⇒ j = [ 1; 2 ]
      ⇒ v = [ 3; 3 ]

Note that this function is particularly useful for sparse matrices, as it extracts the nonzero elements as vectors, which can then be used to create the original matrix. For example:

sz = size (a);
[i, j, v] = find (a);
b = sparse (i, j, v, sz(1), sz(2));

See also: nonzeros.

Package: octave

SourceForge.net Logo
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.