-1

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.

我该如何解决这个错误?

谢谢。

4

1 回答 1

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
于 2013-02-21T22:57:48.590 回答