Dec 14, 2010 #1 T tombraided Newbie level 2 Joined Jan 22, 2010 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Location London Activity points 1,295 Hi there... I have a matrix as: a = [1 3 2 6 8 9 6] can anyone tell how I would be able to get the index of the element(s) for 6. Here the answer should be [4,7]. It should be in matlab. Thanks in advance. -JML
Hi there... I have a matrix as: a = [1 3 2 6 8 9 6] can anyone tell how I would be able to get the index of the element(s) for 6. Here the answer should be [4,7]. It should be in matlab. Thanks in advance. -JML
Dec 15, 2010 #2 J Jack// ani Advanced Member level 3 Joined Dec 2, 2004 Messages 757 Helped 107 Reputation 222 Reaction score 58 Trophy points 1,308 Activity points 5,006 I don't understand how you came up with [4,7]. Anyways, there is command ind2sub for that. And to go backwards sub2ind. Hope this helps
I don't understand how you came up with [4,7]. Anyways, there is command ind2sub for that. And to go backwards sub2ind. Hope this helps
Dec 15, 2010 #3 L LemonTea10 Newbie level 1 Joined Feb 28, 2007 Messages 1 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Activity points 1,285 a = [1 3 2 6 8 9 6]; if you want to get the index of the element(s) for 6, you should type with the following command find(a == 6) Therefore, the answer is 4 and 7 ps. I use matlab version 7.6 (R2008a) with the above command.
a = [1 3 2 6 8 9 6]; if you want to get the index of the element(s) for 6, you should type with the following command find(a == 6) Therefore, the answer is 4 and 7 ps. I use matlab version 7.6 (R2008a) with the above command.