1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: 2D array data manipulation

  1. Jun 12, 2014 #1


    User Avatar
    Gold Member

    1. The problem statement, all variables and given/known data

    2. Relevant equations

    3. The attempt at a solution
    Code (Text):
    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 (Text):
    [mVal, I] = max(A,[],1)

    mVal =

        8.3000    5.3000    6.7000

    I =

         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?

    Attached Files:

  2. jcsd
  3. Jun 12, 2014 #2


    User Avatar
    Science Advisor
    Homework Helper

    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.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted