0
$\begingroup$

Given this Matrix

{{0, 0, 0, 0}, {1, 2, 92.355, 49.}, {1, 7, 86.7407, 46.5}, {6, 2, 
  92.355, 49.}, {6, 7, 87.237, 46.5}}

How can I automatically access the third column entry in the row where the first entry is 1 and the second is 7 (86.7407)?

This automatisation really should look at the first two entries of the rows and then give back the third column number in that row.

$\endgroup$

2 Answers 2

1
$\begingroup$

Try

m={{0,0,0,0},{1,2,92.355,49.},{1,7,86.7407,46.5},{6,2,92.355,49.},{6,7,87.237,46.5}};
Cases[m,{1,7,__}][[1,3]]

which should return 86.7407

The Cases with that pattern will find all rows matching the first two elements and then the [[1,3]] will extract the third element from the first matching row.

$\endgroup$
1
  • $\begingroup$ Thank you Roman and Bill! $\endgroup$
    – user34047
    May 9, 2021 at 14:04
0
$\begingroup$
data = {{0, 0, 0, 0}, {1, 2, 92.355, 49.}, {1, 7, 86.7407, 46.5},
        {6, 2, 92.355, 49.}, {6, 7, 87.237, 46.5}};

FirstCase[data, {1, 7, x_, ___} -> x]
(*    86.7407    *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.