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

Home » Public Forums » archive » HELP adding arrays
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
HELP adding arrays [message #91536] Sun, 26 July 2015 08:30 Go to next message
Dete van Eeden is currently offline  Dete van Eeden
Messages: 32
Registered: July 2015
Member
Hallo

I have posted before but I still cant add arrays together!

I have tried the total command:

finaal=fltarr(1508)
values=fltarr(1508,6)

finaal=total(values,2)

finaal is equal to the last array...

I have also tried

finaal=fltarr(1508)
values=fltarr(1508,6)

finaal=temporary(finaal) + values[*,j]

finaal is Still equal to the last array

What the hell?!

It cant be that difficult......
Re: HELP adding arrays [message #91537 is a reply to message #91536] Sun, 26 July 2015 10:41 Go to previous messageGo to next message
dg86 is currently offline  dg86
Messages: 118
Registered: September 2012
Senior Member
On Sunday, July 26, 2015 at 11:30:16 AM UTC-4, Dete van Eeden wrote:
> Hallo
>
> I have posted before but I still cant add arrays together!
>
> I have tried the total command:
>
> finaal=fltarr(1508)
> values=fltarr(1508,6)
>
> finaal=total(values,2)
>
> finaal is equal to the last array...
>
> I have also tried
>
> finaal=fltarr(1508)
> values=fltarr(1508,6)
>
> finaal=temporary(finaal) + values[*,j]
>
> finaal is Still equal to the last array
>
> What the hell?!
>
> It cant be that difficult......

Your "values" all have the value zero. The sum is working, but you're
only adding up the value zero. Try this ...

IDL> values = findgen(5, 6) ; create a small index array for demo
IDL> finaal = total(values, 2) ; sum over the second dimension
IDL> print, finaal
75.000000 81.000000 87.000000 93.000000 99.000000

It works!

All the best,

David
Re: HELP adding arrays [message #91538 is a reply to message #91536] Sun, 26 July 2015 10:46 Go to previous messageGo to next message
Dete van Eeden is currently offline  Dete van Eeden
Messages: 32
Registered: July 2015
Member
Thanks David

The 'values' actually consists of values....

I just skipped the part where I open the files and read them.

If a have an array (1508,6) and I sum over the second dimension... does it add all the values (1508 of them) over the six different arrays?
Re: HELP adding arrays [message #91539 is a reply to message #91536] Sun, 26 July 2015 10:49 Go to previous messageGo to next message
Dete van Eeden is currently offline  Dete van Eeden
Messages: 32
Registered: July 2015
Member
for j=0,5 do begin

.....

openr,l,File4,/get_lun

readf,l,val

values(*,j) = val
Re: HELP adding arrays [message #91540 is a reply to message #91536] Sun, 26 July 2015 10:51 Go to previous messageGo to next message
Dete van Eeden is currently offline  Dete van Eeden
Messages: 32
Registered: July 2015
Member
for j=0,5 do begin

...go to the filename etc....

openr,l,File4,/get_lun

readf,l,val

values(*,j) = val

free_lun

finaal =temporary(finaal) + values[*,j]

or finaal = total(values,2)

endfor

it doesnt work
Re: HELP adding arrays [message #91542 is a reply to message #91540] Sun, 26 July 2015 12:41 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Dete van Eeden writes:

> for j=0,5 do begin
>
> ...go to the filename etc....
>
> openr,l,File4,/get_lun
>
> readf,l,val
>
> values(*,j) = val
>
> free_lun
>
> finaal =temporary(finaal) + values[*,j]
>
> or finaal = total(values,2)
>
> endfor
>
> it doesnt work

Uh, take the TOTAL calculation out of your loop. :-)

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Current color table
Next Topic: cgsymbols change when saving from cgwindow to pdf

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

Current Time: Wed Oct 08 14:11:32 PDT 2025

Total time taken to generate the page: 0.00449 seconds