Prev: Simultaneous Nonlinear Data Fits
Next: How do you get Mathematica to evaluate "Floor" to give a number?
From: Bob Hanlon on 10 Apr 2010 06:54 n=5; x=RandomReal[{0,1}, n]; y=RandomReal[{0,1}, n]; pts=Thread[{x,y}]; {a,b}={.25,.75}; filtered1=If[a<#[[1]]<b,{1,0}#,#]&/@pts or filtered2={1,If[a<#[[1]]<b,0,1]}#&/@pts or filtered3={1,1-Boole[a<#[[1]]<b]}#&/@pts filtered1==filtered2==filtered3 True Bob Hanlon ---- Charles Koehler <cjkphd(a)wi.rr.com> wrote: ============= Hello, If possible I could use a little help on this. I have a list of x and y data and based on the value of x I would like to manipulate the value y. I joined the data using: pts=MapThread[{##1}&,{x,y}] I assumed that by testing the x value using #[[1]], I could change the value of y using #[[2]] as shown below. If no manipulation was required based on the value of x, I would keep that point unchanged, but I'm definitely missing something. filtered=If[a<#[[1]]&<b,#[[2]]&=0],{#[[1]],#[[2]]}&,pts] a and b are the range of x values Any insight would be much appreciated. Thanks, Chuck Koehler |