Prev: 30 Days Free Trial Project Management Software
Next: How to generate a random strongly connected graph??
From: Peter Riddersholm on 16 Jun 2010 02:39 Let's say that there is a 5x5 array, A: A=magic(5) A = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 3 11 18 25 2 9 What function will find the row and column number for the element with value 6? I am sorry for this simple question, but I simply cannot find it :( /peter
From: Bruno Luong on 16 Jun 2010 03:12 "Peter Riddersholm " <peri(a)dmi.dk> wrote in message <hv9ri9$ej$1(a)fred.mathworks.com>... > Let's say that there is a 5x5 array, A: > > A=magic(5) > > A = > > 17 24 1 8 15 > 23 5 7 14 16 > 4 6 13 20 22 > 10 12 19 21 3 > 11 18 25 2 9 > > What function will find the row and column number for the element with value 6? > > I am sorry for this simple question, but I simply cannot find it :( You cannot FIND the function that can FIND row and column? Did you try "FIND"? Bruno
From: Peter Riddersholm on 16 Jun 2010 04:55 "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hv9tg3$17q$1(a)fred.mathworks.com>... > "Peter Riddersholm " <peri(a)dmi.dk> wrote in message <hv9ri9$ej$1(a)fred.mathworks.com>... > > Let's say that there is a 5x5 array, A: > > > > A=magic(5) > > > > A = > > > > 17 24 1 8 15 > > 23 5 7 14 16 > > 4 6 13 20 22 > > 10 12 19 21 3 > > 11 18 25 2 9 > > > > What function will find the row and column number for the element with value 6? > > > > I am sorry for this simple question, but I simply cannot find it :( > > You cannot FIND the function that can FIND row and column? Did you try "FIND"? > > Bruno I might not be the best ML programmer, but could you help me a bit further? [row,col]=find(A) returns the indices of nonzero elements. How do I get - for instance - the row and column number for the element with value 6 using find? /peter
From: Jos (10584) on 16 Jun 2010 05:34 "Peter Riddersholm " <peri(a)dmi.dk> wrote in message <hva3hq$nhp$1(a)fred.mathworks.com>... > "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hv9tg3$17q$1(a)fred.mathworks.com>... > > "Peter Riddersholm " <peri(a)dmi.dk> wrote in message <hv9ri9$ej$1(a)fred.mathworks.com>... > > > Let's say that there is a 5x5 array, A: > > > > > > A=magic(5) > > > > > > A = > > > > > > 17 24 1 8 15 > > > 23 5 7 14 16 > > > 4 6 13 20 22 > > > 10 12 19 21 3 > > > 11 18 25 2 9 > > > > > > What function will find the row and column number for the element with value 6? > > > > > > I am sorry for this simple question, but I simply cannot find it :( > > > > You cannot FIND the function that can FIND row and column? Did you try "FIND"? > > > > Bruno > > I might not be the best ML programmer, but could you help me a bit further? > > [row,col]=find(A) > > returns the indices of nonzero elements. How do I get - for instance - the row and column number for the element with value 6 using find? > > /peter You need to convert the input to FIND into an logical array: A = magic(3) B = A == 6 [r,c] = find(B) % % in 1 step: [r,c] = find(A==6) Jos
From: Bruno Luong on 16 Jun 2010 05:37 To find elements equal to 6, use [row,col]=find(A==6) And don't forget to read "Getting Started" document. Bruno
|
Next
|
Last
Pages: 1 2 Prev: 30 Days Free Trial Project Management Software Next: How to generate a random strongly connected graph?? |