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 #66290 is a reply to message #66287] Tue, 05 May 2009 04:53 Go to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
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. See
http://dfanning.com/tips/histogram_tutorial.html for more on that - it
is the swiss knife of IDL.

CHeers,
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 09:12:32 PDT 2025

Total time taken to generate the page: 0.62806 seconds