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

Home » Public Forums » archive » Re: Adding or deduct values in a ARRAY
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Adding or deduct values in a ARRAY [message #52156] Fri, 19 January 2007 08:37
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On Fri, 19 Jan 2007 17:36:43 +0100, Wox <nomail@hotmail.com> wrote:

> On 19 Jan 2007 05:32:26 -0800, "Erik" <janssen.e@gmail.com> wrote:
>
>> These are the good values, however as stated before I want the array to
>> stay a [3,4] array with the old Y and Z values still stored in it.
>
>
> IDL> arr1=indgen(3,4)
> IDL> print,arr1
> 0 1 2
> 3 4 5
> 6 7 8
> 9 10 11
> IDL> arr1[0,*]-=10
> IDL> print,arr1
> -10 1 2
> -7 4 5
> -4 7 8
> -1 10 11


OK, you got it :-)
Re: Adding or deduct values in a ARRAY [message #52157 is a reply to message #52156] Fri, 19 January 2007 08:36 Go to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On 19 Jan 2007 05:32:26 -0800, "Erik" <janssen.e@gmail.com> wrote:

> These are the good values, however as stated before I want the array to
> stay a [3,4] array with the old Y and Z values still stored in it.


IDL> arr1=indgen(3,4)
IDL> print,arr1
0 1 2
3 4 5
6 7 8
9 10 11
IDL> arr1[0,*]-=10
IDL> print,arr1
-10 1 2
-7 4 5
-4 7 8
-1 10 11
Re: Adding or deduct values in a ARRAY [message #52158 is a reply to message #52157] Fri, 19 January 2007 06:01 Go to previous message
Erik[1] is currently offline  Erik[1]
Messages: 23
Registered: December 2006
Junior Member
Hey Ben and Wox,

You are right, I overlooked the '-=' operator. Thanks for your help!!
Re: Adding or deduct values in a ARRAY [message #52159 is a reply to message #52158] Fri, 19 January 2007 05:45 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Erik wrote:
> Hey Wox,
>
> Thanks for your reply.
>
> I've tried ARR1[0,*] -10 and ARR1[0,*,*] -10 (both the same)
>
> Then I got a float array with dimensions [1, 4]
>
> 83.0000
> 83.0000
> 141.000
> 141.000
>
> These are the good values, however as stated before I want the array to
> stay a [3,4] array with the old Y and Z values still stored in it.
>

Hello Erik,

I think you might have missed the subtle syntax that Wox posted. It
both reduced the first column by 10 AND assigned the result to the
original column.

IDL> arr1 = FINDGEN(3,4)
IDL> print, arr1
0.00000 1.00000 2.00000
3.00000 4.00000 5.00000
6.00000 7.00000 8.00000
9.00000 10.0000 11.0000

the following is the assignment that reduces the first column by 10,
this is the "traditional" way to do it and it is pretty clear

IDL> arr1[0,*] = arr1[0,*] - 10
IDL> print, arr1
-10.0000 1.00000 2.00000
-7.00000 4.00000 5.00000
-4.00000 7.00000 8.00000
-1.00000 10.0000 11.0000

and the following syntax does the same thing (note the "-=") even though
it is a little less obvious until you get used to it

IDL> arr1[0,*] -= 10
IDL> print, arr1
-20.0000 1.00000 2.00000
-17.0000 4.00000 5.00000
-14.0000 7.00000 8.00000
-11.0000 10.0000 11.0000

most likely you have been assigning the result of the subtraction to a
new variable which assigns the new variable the (changed) value of the
first column

IDL> arr2 = arr1[0,*] - 10
IDL> print, arr2
-30.0000
-27.0000
-24.0000
-21.0000

Does the help?
Ben
Re: Adding or deduct values in a ARRAY [message #52160 is a reply to message #52159] Fri, 19 January 2007 05:32 Go to previous message
Erik[1] is currently offline  Erik[1]
Messages: 23
Registered: December 2006
Junior Member
Hey Wox,

Thanks for your reply.

I've tried ARR1[0,*] -10 and ARR1[0,*,*] -10 (both the same)

Then I got a float array with dimensions [1, 4]

83.0000
83.0000
141.000
141.000

These are the good values, however as stated before I want the array to
stay a [3,4] array with the old Y and Z values still stored in it.

regards,
Erik
Re: Adding or deduct values in a ARRAY [message #52161 is a reply to message #52160] Fri, 19 January 2007 05:19 Go to previous message
Wox is currently offline  Wox
Messages: 184
Registered: August 2006
Senior Member
On 19 Jan 2007 05:08:03 -0800, "Erik" <janssen.e@gmail.com> wrote:

> Hi Folks,
>
> I have a (assumable) simple question. I have an array like this:
>
> ARR1 FLOAT = Array[3, 4]
> 93.0000 118.000 0.000000
> 93.0000 73.0000 0.000000
> 151.000 73.0000 0.000000
> 151.000 118.000 0.000000
>
> The array contain's four [x,y,z] coordinates. Now I want all the X
> coordinates lowered by 10. The result should be:
>
> ARR1 FLOAT = Array[3, 4]
> 83.0000 118.000 0.000000
> 83.0000 73.0000 0.000000
> 141.000 73.0000 0.000000
> 141.000 118.000 0.000000
>
> I've tried ARR1-10 but then all the values are deducted by 10.
> When I try ARR1[*,*,*] - 10, then I've get an array with all the X/Y/Z
> values lowered.
> When I try ARR1[*,0,0] - 10, then I've get an array with with only 3
> dimensions float[3]
>
>
> How can I select a specific dimension to edit so I can get the result
> which is described above.
>
> Thanks in advance!!
>
> Erik


arr1[0,*]-=10
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Adding or deduct values in a ARRAY
Next Topic: Avoiding loop stats

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

Current Time: Wed Oct 08 11:37:35 PDT 2025

Total time taken to generate the page: 0.00629 seconds