符合特定标准的像素位置

时间:2013-02-21 22:42:13

标签: matlab location pixel

matlab中,以下表示return me the values of x for which y=1

c = x(y == 1)

但是,如何返回这些像素的location

我试过了:

 [i,j] = x(y == 1)

但是,出现了以下错误:

??? Indexing cannot yield multiple results.

如何解决此错误?

感谢。

1 个答案:

答案 0 :(得分:1)

只需使用find

ind=find(y==val)

例如:

y=[1 0 2 0 3];
find(y==3)

ans =
     5

或者对于矩阵:

 y=[1 2 3 ; 4 5 6 ; 7 8 9];
 [row col] = find(y==5)

row =
     2
col =
     2