2014-03-05 32 views
0

假設我有一個矩陣M 500×如何從矩陣M MATLAB求n指數的最大價值指數

,我想找到前100指數具有併購

我的想法是最值是按降序排序的數據M和使用find比較

[x,y] = find(M == sort(M(:),'descend'), 100, 'first'); 

但是當我運行該程序,我發現錯誤

我想大概M == sort(M(:),'descend') THI s part

你能幫助我嗎?

+0

嘗試使用'M(:,:)'代替'M(:)',因爲您的矩陣是二維的 – Ankush

回答

1

你不需要find。只需使用第二個輸出sort

[~, iSorted] = sort(M(:),'descend'); 
[x y] = ind2sub(size(M), iSorted(1:100));