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

Home » Public Forums » archive » ERROR: Attempt to subscript B with is out of range
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: ERROR: Attempt to subscript B with is out of range [message #89921 is a reply to message #89912] Sat, 27 December 2014 10:32 Go to previous message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Wednesday, December 24, 2014 6:52:13 AM UTC-5, g.na...@gmail.com wrote:
> Hi
>
> I've got a 3D array B[100,200,200]. My array B sometimes contains negative values and other times very large values. In order to make sure that when there are either negative or very large values will set to zero I wrote the following code:
>
> FOR i=0L,199 DO BEGIN
> FOR j=0L,199 DO BEGIN
> WRONG = total((B[*,i,j] LT 0) OR (B[*,i,j] GT 10000))
> IF WRONG GT 0 THEN B[*,i,j]=0
> ENDFOR
> ENDFOR
>
> I got the error Attempt to subscript B with j is out of range. I cannot figure out with this happen with the j variable. Any idea?

1. Here's a nice idiom for setting negative values to zero

b = b > 0.

An even more compact version:

b >= 0.

2. Masking large values similarly is quick and easy

threshold = 10000
b = b * (b le threshold)

The more compact version is

b *= b le threshold

Summarizing the quick way to achieve your goals
b >= 0. ; set negative values to zero
b *= b le threshold ; set large values to zero

TTFN,

David
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Nested data structures
Next Topic: eps issues with ps_start

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

Current Time: Thu Oct 09 20:31:15 PDT 2025

Total time taken to generate the page: 0.87736 seconds