Re: What is the fastest way to threshold data?
- To: mathgroup at smc.vnet.net
- Subject: [mg85922] Re: What is the fastest way to threshold data?
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Thu, 28 Feb 2008 02:41:16 -0500 (EST)
- Organization: Uni Leipzig
- References: <fq3af1$fot$1@smc.vnet.net>
- Reply-to: kuska at informatik.uni-leipzig.de
Hi, With[{nn = 64}, data = Table[RandomReal[{-1, 1}], {nn}, {nn}, {nn}, {3}] ]; and thdata = Map[If[#[[3]] > 0, #, {1, 1, 0}*#] &, data, {3}]; may help Regards Jens Kevin J. McCann wrote: > I have some 3d data {{x1,y1,z1},{x2,y2,z2},...} and I would like to set > the z-values to zero if they fall below zero. More generally, I would > like to set z to a threshold value if it is at or below a threshold. > This seems as though it should be an easy enough thing to do, but the > only way I have figured out is to parse out the z-vector, do > > mask=((#<thresh&) /@ zdata)/.True->0/.False->1; > > then > zvector = zvector*mask; > > and rebuild the {x,y,z} data. > > Kevin