Find top n elements in matrix

前端 未结 3 1372
春和景丽
春和景丽 2021-01-26 16:39

I have a matrix which contains values and I wish to find the index of the top n minimum values.

I use the following code for finding the minimum most value:

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-26 17:44

    Maybe you could do something like this:

    sorted = sort(Result(:));
    topten = sorted(1:10);
    [~,ia,~] = intersect(Result(:),topten(:)); % // Get the indices of the top ten values
    [r,c]=ind2sub(size(Result),ia); % // Convert the indices to rows and columns
    

提交回复
热议问题