0
|
3904 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# Matrice elements extraction

Posted 10 years ago
 Hi. I need a help  I have defined the matrix "m" and the position ( variable index1) of the line in the first column. How do I extract the element defined by the position calculated and column 2. I want the element m [3,2]. If a use m[[index1,2]] doesn't work. Thanks m = {{20, 0.004, na, na}, {18, 0.05, na, na}, {16, 0.06, na, na}, {14, 0.074, 1.05, 0.5}, {12, 0.0104, 0.92, 0.5}, {10, 0.134, 0.82, na}} In[318]:= index1 = Position[{20, 18, 16, 14, 12, 10}, gagev] Out[318]= {{3}} In[373]:= m[[index1, 2]] During evaluation of In[373]:= Part::pkspec1: The expression {{3}} cannot be used as a part specification. >> Out[373]= {{20, 0.004, na, na}, {18, 0.05, na, na}, {16, 0.06, na, na}, {14, 0.074, 1.05, 0.5}, {12, 0.0104, 0.92, 0.5}, {10, 0.134, 0.82, na}}[[{{3}}, 2]] 
2 Replies
Sort By:
Posted 10 years ago
 Priyan. Thank you very much. 
Posted 10 years ago
 This happens cause index1 equals {{3}} not 3. Hence replace index1 with index1[[1]][[1]] in the m[[index1,2]] term.