如何返回包含最大标签的矢量 [英] How to return a vector containing the labels of the maximum
本文介绍了如何返回包含最大标签的矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个4列数组,我想获得一个向量,其中包含每行包含该行最大值的列标签。
I have a 4 column array, I would like to obtain a vector containing for each row the label of the column which contained the maximum value for this row.
我可以在循环中做到这一点,但我想使用矩阵函数来获得速度。
I can do this in loops but I would like to use matrix functions for speed.
如何在不编程自己的lib函数的情况下做到这一点?
How can I do this without programming my own lib functions ?
推荐答案
有一个功能可以做到这一点。如果 x
是您的矩阵,请尝试 max.col(x)
。
There is a function that does just this. If x
is your matrix, try max.col(x)
.
这篇关于如何返回包含最大标签的矢量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文