Getting Started Previous page   Next Page

The find Function

The find function determines the indices of array elements that meet a given logical condition. In its simplest form, find returns a column vector of indices. Transpose that vector to obtain a row vector of indices. For example, start again with Dürer's magic square. (See The magic Function.)

picks out the locations, using one-dimensional indexing, of the primes in the magic square:

Display those primes, as a row vector in the order determined by k, with

When you use k as a left-hand-side index in an assignment statement, the matrix structure is preserved:


Previous page  Logical Subscripting Controlling Command Window Input and Output Next page

© 1994-2005 The MathWorks, Inc.