このリストは、実際の状況の最小限の例です
list = [0.2 0.1 0.3 0.4 0.7 0.5 0.6 0.9 1.0];
並べます
sorted_list = sort(list, 'descend');
listで最も高い値を持つインデックスの 10% を取得する必要があります。
私の試み
% Take the amount of indexes to 10%
limit = size(sorted_list);
size = limit(1);
limit = ceil(0.1*size);
% find the index numbers from the original list which corresponds to the highest indexes
for j = 1:limit
value = sorted_list(j);
for k = 1:size
if value == list(k)
refine_set(j) = k;
% here much resources used, should be able stop if matching
% early, so should be able to stop the for-loop somehow
% I do not want to use while-loop, since in some cases, this would cause
% infinite loop
end;
end;
end;
これを行うためのより良い方法がなければならないと考え始めています。関数maxには、最大値の 10% を表すインデックスを取得できるパラメーターがないようです。
リスト内の 10% の最大値を表す元のリストのインデックスを取得する良い方法は何ですか?
このタスクに適したデータ構造は何ですか?