Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在matlab以下方式return me the values of x for which y=1
matlab
return me the values of x for which y=1
c = x(y == 1)
但是,我怎样才能返回location那些像素。
location
我试过:
[i,j] = x(y == 1)
但是,得到以下错误:
??? Indexing cannot yield multiple results.
我该如何解决这个错误?
谢谢。
只需使用find
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