• Matlab TutorialsNo Comments

    default thumbnail

    Function

    The find function determines the indices of 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 ,

    k = find((A))'

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

    k =
         2     5     9    10    11    13

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

    A(k)
    ans =
         5     3     2    11     7    13

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

    A(k) = NaN
    A =
        16   NaN   NaN   NaN
       NaN    10   NaN     8
         9     6   NaN    12
         4    15    14     1
    You might also be interested in :  beep

    Comment closed!