简体   繁体   English

[ab] = max(.9) 在 Matlab 中做什么?

[英]What does [a b] = max(.9) do in Matlab?

This doesn't make any sense to me and I'm not sure what to even search for.这对我来说没有任何意义,我不知道该搜索什么。

Matlab code: MATLAB代码:

[a b] = max(.9);

Output:输出:

a =
      0.9

b = 
      1

Why is it increasing by 1/10?为什么会增加 1/10? What does [ab] do when on the left side of equal sign? [ab] 在等号左边有什么作用?

max is used to find the maximum value of an array. max用于查找数组的最大值。 The second output (if requested), returns the index that corresponds to the first value in the array that is equal to the maximum value .第二个输出(如果请求) 返回与数组中第一个值对应的索引,该值等于最大值

[max_value, max_index] = max([1 3 3 2]);
%   max_value = 3
%   max_index = 2

In your case, you are passing a scalar (a 1 x 1 array) to max , therefore the scalar is the maximum and the maximum appears at index 1.在您的情况下,您将一个标量(一个1 x 1数组)传递给max ,因此标量是最大值,最大值出现在索引 1 处。

[M,I] = max(A) finds the indices of the maximum values of A and returns them in output vector I, using any of the input arguments in the previous syntaxes. [M,I] = max(A) 使用前面语法中的任何输入参数,找到 A 的最大值的索引并在输出向量 I 中返回它们。 If the maximum value occurs more than once, then max returns the index corresponding to the first occurrence.如果最大值出现多次,则 max 返回与第一次出现对应的索引。

Reference: https://www.mathworks.com/help/matlab/ref/max.html?requestedDomain=www.mathworks.com参考: https : //www.mathworks.com/help/matlab/ref/max.html?requestedDomain=www.mathworks.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM