comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: replace array's elemets
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: replace array's elemets [message #35189 is a reply to message #35188] Fri, 16 May 2003 09:00 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Roberto wrote:
> Hi
> I have a 100x100 array.
> How can I replace an element if is different from 0?
> I would replace all elements different from 0 with 1.
> thank and sorry for the trouble.
> Roberto

Hi Roberto,

You can use the WHERE function to get the indices of the elements that
match your value (in your case 0). You do need to be a bit careful if
your array is floating decimal type - in that case you must think about
machine precision issues. Search on Google for more info about this.


indices = where(myArray EQ someValue, count)

if count NE 0 then myArray[indices] = 1


If you are new to IDL, I encourage you get one of the very good
introductory manuals that are available. Your won't reget it.

Liam Gumley's www.gumley.com
David Fanning's www.dfanning.com
Ronn Kling's www.rlkling.com

Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: plotting from high values to low values
Next Topic: read pixels

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:00:05 PDT 2025

Total time taken to generate the page: 0.00414 seconds