Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'max element in matrix' topicStudent Support Forum > General > "max element in matrix"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
10/18/12 1:29pm

If you want to know the biggest element and where it is then you must keep track of the biggest element seen thus far and update that each time a bigger element is seen.

In[1]:= A={{1.1161`,0.1254`,0.1397`,0.149`},{0.1582`,1.1675`,0.1768`,0.1871`},{0.1968`,0.2071`,1.2168`,0.2271`},{0.2368`,0.2471`,0.2568`,1.2671`}};
biggest=A[[1,1]];xpos=1;ypos=1;
For[i=1,i≤4,i++,
For[j=1,j≤4,j++,
If[Abs[biggest]<Abs[A[[i,j]]], biggest=A[[i,j]];xpos=i;ypos=j]
]
];
{biggest,xpos,ypos}

Out[5]= {1.2671,4,4}

URL: ,

Subject (listing for 'max element in matrix')
Author Date Posted
max element in matrix Tatjana 10/18/12 01:29am
Re: max element in matrix Bill Simpson 10/18/12 1:29pm
Re: max element in matrix Peter Pein 10/19/12 1:54pm
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic