Simple, do the same but with max() instead of min(). The associated column number is 4, as per followings: octave:72> = min(min(A,1)) The associated row number is 2, as per followings: octave:76> = min(min(A,2)) To find the associated row and column programmatically, just simply do this. (Note: the assiciated location is row 2, column 4 - if you scan through the matrix manually). The minimum value may be found easily by doing this: octave:71> min(min(A)) Say we have a Matrix A that look like this: octave:69> A = rand(3,4) Note that Octave index start from 1 (instead of 0). This article summarises my solution to this problem (which, hopefully this will also come in hadny to you!). The max function can also return the index of the maximum value in the vector. Given a Matrix A with m rows, and n columns find the mininum (or maximum) value and the associated row and column number How do you find the index of the max value in an array in Matlab val, idx max (A,, 2) The idx part will contain the column number of containing the max element of each row. Whilst working through the many (Octave) coding assignment from Andrew Ng's Stanford Machine Learning course, a common problem that I have to solve revolves around this:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |