What is the purpose of max(A,[],1)?

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
1 reply · 2K views
gfd43tg
Gold Member
Messages
949
Reaction score
48

Homework Statement


Homework Equations


The Attempt at a Solution


Code:
A = [2.1, 4.2, 6.7; 8.3, 5.3, 5.4]

A =

    2.1000    4.2000    6.7000
    8.3000    5.3000    5.4000

Code:
[mVal, I] = max(A,[],1)

mVal =

    8.3000    5.3000    6.7000I =

     2     2     1
I don't understand what max(A,[],1) is doing. The mVal is a maximum values. The I is the index of those maximum values. What is the [] and 1 for?
 

Attachments

  • 2D arrays data manipulation.jpg
    2D arrays data manipulation.jpg
    22.2 KB · Views: 539
Physics news on Phys.org
I think the [] is just a placeholder for the second argument. There are 3 versions of max, with 1, 2, and 3 arguments.

Matlab syntax often gives me the feeling that somebody just made it up as they went along, rather than designing it to be logical, consistent, rational, etc.

http://www.mathworks.co.uk/help/matlab/ref/max.html