I have a matrix


I can find certain elements with this statement

list=Select[m,(10 < #[[1]] < 50 ) && (#[[2]] < 6) &]

and I get


How can I use DeleteCases to remove the items {10,2} and {50,6}? I know I can invert the logic on the Select case, but I'd like learn to use DeleteCases, but can't figure out the right syntax for the selection. A one dimensional list is more straight forward, but I'm having trouble generalizing to higher dimensions.

Also, can anyone point me to clear documentation on selection syntax, as I am only mimicing the syntax I see in working examples and that often doesn't work.


DeleteCases[m , _?(Not[10 < #[[1]] < 50 && #[[2]] < 6] &)]

{{20, 3}, {30, 4}, {40, 5}}


It is unclear just what criteria you're seeking. It is easy to "remove the first and last items" by Delete[m, 1] and Delete[m, -1] or

Delete[m, {{1}, {-1}}].  

What mathematical criteria do you wish to invoke?

  • $\begingroup$ What you offer is also useful, but I was looking for deleting certain elements which meet certain criteria. The fact that the selected items were the 1st and last items was just a coincidence. I will modify my original question $\endgroup$ – Tom Mozdzen Apr 13 '17 at 21:06

Your Answer

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

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