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

Home » Public Forums » archive » Adding elements in an Array
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: Adding elements in an Array [message #85968 is a reply to message #85967] Sun, 22 September 2013 11:46 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
bhattacharjee12@gmail.com writes:

>
> Hi,
> I am new to IDl. I was hoping if you guys can help with my problem.
> I will explain my problem with an example.
> Lets say I have an array
> x=[1,2,3,4,5,6,1,2,3]
> & I want to average lets say every 3 elements and put the results in a new array say y
> Where y would look like
> y=[2,5,2]
> Is there a nifty IDL function/easy way which would do that?

IDL> x=[1,2,3,4,5,6,1,2,3]
IDL> x = reform(x, 3, 3)
IDL> b = Mean(x, dimension=1)
IDL> print, b
2.00000 5.00000 2.00000

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.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Google Street Maps
Next Topic: idl: turn string value into variable name part2

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

Current Time: Sun Oct 12 11:11:37 PDT 2025

Total time taken to generate the page: 1.76189 seconds