Searching matrix for a particular value and ploting it

hi there. Say I have a matrix A = [1 2 3; 2 1 5; 6 7 5;8 2 1]. and i want to search for the value '1' in the matrix then plot it according to the row and column it occurs in.
ex: the x,y coordinates for plotting would be:
(1,1) ==> 1 for the row and 1 for the column (2,2) ==> 2 for the row and 2 for the column (0,0) ==> nothing because there is no 1 in this row (4,3) ==> 4 for the row and 3 for the column
any help would be appreciated. thnx in advance

 Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 14 Dez. 2012
Bearbeitet: Andrei Bobrov am 14 Dez. 2012
A = [1 2 3; 2 1 5; 6 7 5;8 2 1];
[row,col] = find(A == 1);
or
[row,col] = find(abs(A - 1) < eps(100));
out = [row,col];

Weitere Antworten (0)

Kategorien

Mehr zu Fractals finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by