MATLAB: Please explain the above commands,

matrix

a=[7 3 5; 6 2 1]; dd=find(a<4)
dd =
3
4
6
How it is possible to display the 4 in that ans? and my condition is to find the <4 values in matrix a. But how it was display the 4 also?
Please anyone explain me…

Best Answer

  • Ramya, dd contains the position numbers of all elements in matrix a that are smaller than 4, which would be 3, 2, and 1.
    a =
    7 3 5
    6 2 1
    The position number of the elements is counted sequentially row by row, and column by column:
    1 3 5
    2 4 6
    If you want row and column indices use
    [r,c] = find(a<4)