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

Home » Public Forums » archive » Re: newbie question on array manipulation
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: newbie question on array manipulation [message #66285 is a reply to message #66283] Tue, 05 May 2009 06:24 Go to previous messageGo to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On May 5, 7:53 am, "ben.bighair" <ben.bigh...@gmail.com> wrote:
> On May 5, 7:40 am, jpardila <blu...@gmail.com> wrote:
>
>> What is the best way to manipulate one array and remap its values
>> according to conditions?
>> Let's say I have a 2-d array, for all the elements equal to 5 I want
>> to change their values to 0. For values equal to 10 I want to convert
>> to 1 and so on. I am really confused and don't know if to use IF,
>> where, for or while. Thanks for answering this basic one.
>> JP
>
> Hi,
>
> The simplest is to use where - don't forget to use the output COUNT
> argument shown here as "na".
>
> a = WHERE(array EQ 10, na)
> if (na GT 0) then array[a] = 1
>
> If you are doing a multiple replacements (of different values) in a
> single array then you'll want to strap your sneakers on and use
> HISTOGRAM with it's REVERSE_INDICES output keyword. Seehttp://dfanning.com/tips/histogram_tutorial.htmlfor more on that - it
> is the swiss knife of IDL.
>

Hi again,

Another thought after a cup of coffee... if your application uses
floating point values instead of integers then you should search this
news group for info on how to test for equality with floats (single or
double precision).

Cheers (again),
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: newbie question on array manipulation
Next Topic: Trying to run ENVI_FX_DOIT example

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

Current Time: Fri Oct 10 13:03:14 PDT 2025

Total time taken to generate the page: 0.24572 seconds