1
$\begingroup$

I am facing a problem to select data from a list {Xn,Yn,Zn}. Now I need to select data with a criteria Xn^2+Yn^2=1. How to write the criteria in select function?

$\endgroup$
  • $\begingroup$ Try Select[data, (#[[1]]^2 + #[[2]]^2 == 1) &] $\endgroup$ – BlacKow Oct 16 '16 at 3:06
  • $\begingroup$ Or Select[data, Total[Most[##]^2] == 1 &] $\endgroup$ – Bob Hanlon Oct 16 '16 at 3:31
  • $\begingroup$ Select[data, Norm[Most[#]] == 1 &] is also possible. $\endgroup$ – J. M. will be back soon Oct 16 '16 at 3:41
  • $\begingroup$ Sometimes it is hard to find points that lie precisely on the cylinder, because of round-off, etc. If you want the points that lie inside the cylinder, try Select[data, Element[Most[#], Ball[{0, 0}]] &] $\endgroup$ – LouisB Oct 16 '16 at 4:27
  • $\begingroup$ I apologise for my lazyness to login. Thanks a lot for the comments $\endgroup$ – Dai Weijing Oct 7 '17 at 7:02

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.