MATLAB:[Y,I] = max(AS,[],2);是什么? [英] MATLAB: What's [Y,I]=max(AS,[],2);?
问题描述
我刚开始使用matlab,需要非常快地完成此程序,所以我没有时间阅读所有教程.
I just started matlab and need to finish this program really fast, so I don't have time to go through all the tutorials.
熟悉它的人可以解释下面的语句在做什么吗.
can someone familiar with it please explain what the following statement is doing.
[Y,I]=max(AS,[],2);
AS
和2
之间的[]
最让我感到困惑.最大值是否同时分配给Y
和I
?
The []
between AS
and 2
is what's mostly confusing me. And is the max value getting assigned to both Y
and I
?
推荐答案
C = max(A,[],dim)
返回标量dim指定的沿A维度的最大元素.例如,max(A,[],1)
沿A
的第一个维度(行)产生最大值.
C = max(A,[],dim)
returns the largest elements along the dimension of A specified by scalar dim. For example, max(A,[],1)
produces the maximum values along the first dimension (the rows) of A
.
此外,[C, I] = max(...)
表单还为您提供了C
中的最大值,并在I
中提供了它们的 indices (即位置).
Also, the [C, I] = max(...)
form gives you the maximum values in C
, and their indices (i.e. locations) in I
.
您为什么不尝试这样的示例?将其输入到MATLAB中,然后看看会得到什么.它应该使事情更容易看到.
Why don't you try an example, like this? Type it into MATLAB and see what you get. It should make things much easier to see.
m = [[1;6;2] [5;8;0] [9;3;5]]
max(m,[],2)
这篇关于MATLAB:[Y,I] = max(AS,[],2);是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!