2013-02-21 111 views
-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. 

我該如何解決這個問題?

謝謝。

回答

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 
+0

當我用這個令人驚訝的我得到錯誤的結果。 – Simplicity 2013-02-21 23:05:40

+0

你可能做錯了什麼,看看我的例子 – bla 2013-02-21 23:12:22

+1

只是爲了補充'[val ind] = find(y == 3)'將yeild既位置和值... – 2013-02-21 23:19:04

相關問題