在矩阵中查找前n个元素 [英] Find top n elements in matrix

查看:108
本文介绍了在矩阵中查找前n个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含值的矩阵,我希望找到n个最小值的索引.

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:

[r,c]=find(Result==min(min(Result)));

我找不到其他问题堆栈溢出,回答了这个问题,请帮忙

I cant find any other questions on stack overflow which answer the question, please help

推荐答案

也许您可以执行以下操作:

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

这篇关于在矩阵中查找前n个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆