简体   繁体   中英

Max function and brackets in Matlab

Why is it that the code:

[a,b] = max([1,2,3;4,5,6;7,8,9])

produces a =

 7     8     9

b =

 3     3     3

Should a be the max number in each of the rows so 5,6,9 and b be the max number in each of the columns so 7,8,9?

7, 8, 9 are the max in each column of your matrix, and 3, 3, 3 are the positions of that max number.

Vector 'a' stores the max numbers, and vector 'b' stores the indexes in each vector.

I suggest reading matlab doc for more details if you want to get the max for each row.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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