0
$\begingroup$

I have a matrix as:

a01={{225., 1, 2, 3, 4}, {225.5, 2, 3, 4, 5}, {226., 3, 4, 5, 6}, {226.5, 4,5,6,7}}

And I want to choose head:

{225,__} and {225.5,__},

But I use the functions like

Cases[a01,{225|225.5,__}]

the output is {{225.5, 2, 3, 4, 5}} rather than {{225., 1, 2, 3, 4},{225.5, 2, 3, 4, 5}}

The reason might cause from 225 in matrix a01 is not integer that can not be selected.

How can I get the correct matrix {{225., 1, 2, 3, 4},{225.5, 2, 3, 4, 5}} both 225 & 225.5 with input 225 is integer?

$\endgroup$
  • 4
    $\begingroup$ try Cases[a01,{225.|225.5,__}] or Cases[a01, N@{225 | 225.5, __}]? $\endgroup$ – kglr Oct 14 '19 at 6:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.