MATLAB Answers

max function to receive maximum element of the row

1 ビュー (過去 30 日間)
Mridul Shrotriya
Mridul Shrotriya 2019 年 6 月 25 日
回答済み: Pullak Barik 2019 年 6 月 25 日
A = [2 4 5 6; 5 8 9 6; 8 9 5 6]
max(A,[],2)
The above code provide maximum element from the each row. I came across to max(A,[ ],2) online only. Can you please tell me the logic behind it, what actually matlab is understanding from max(A,[ ], 2)?

  0 件のコメント

サインインしてコメントする。

採用された回答

Pullak Barik
Pullak Barik 2019 年 6 月 25 日
Firstly, here's the link to the documentation on the max function- max.
Use the link to understand more about the max function.
As to your query, here's what max(A, [ ], 2) does-
1) The max keyword tells that the maximum value has to be extracted from a vector/matrix
2) The first argument, 'A', is to pass the matrix A to the function.
3) The second argument is optional, and is used to pass a second matrix/vector to find out the maximum element from. That is, had the code been written as max(A, B), it would have returned the element from a corresponding dimension that was the largest among all elements from both A and B. Here, '[ ]' denotes that the maximum element is only to be returned from each dimension of the first argument only.
4) The third argument, '2', is used to tell the function that the maximum has to be found along the 2nd dimension (i.e, in this case, the maximum among all the columns in each row).

  0 件のコメント

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by