Re: Split an int array into different arrays [message #83398] |
Mon, 04 March 2013 06:04 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Krishnakumar M.A writes:
> Thanks for the sudden reply. I tried that but what it is not "splitting" the dataset into different arrays, instead giving the same data set in each new array, which is not I wanted. I made some confusion in the question, i think. What i require is to split a large array, say array(1000) to arrays(100), in which i will be getting first 100 points in the first column then the next 100 in the 2nd column and so on. but that is not happening with the reform command?
> Did I do anything wrong?
Probably you just forgot to mention "columns". We all think "rows"
around here. Try this:
array = Indgen(100)
foldedArray = Transpose(Reform(array, 10, 10))
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.")
|
|
|
Re: Split an int array into different arrays [message #83399 is a reply to message #83398] |
Mon, 04 March 2013 06:00  |
Krishnakumar M.A
Messages: 19 Registered: March 2013
|
Junior Member |
|
|
On Monday, March 4, 2013 5:59:42 PM UTC+5:30, Mats Löfdahl wrote:
> Den måndagen den 4:e mars 2013 kl. 13:11:57 UTC+1 skrev Krishnakumar M.A:
>
>> Dear All,
>
>>
>
>> I am writing a simulation in which I have to deal with a large 1D integer array and want to split it into different arrays of same length and add them one over the other, like folding. Are there any function of idl which will do it? It will be very helpful to me, if anyone can solve this.
>
>
>
> Sounds like you could do it by first REFORMing the large 1D array to a 2D array (the "folding") and then use TOTAL to sum over one of the dimensions.
Thanks for the sudden reply. I tried that but what it is not "splitting" the dataset into different arrays, instead giving the same data set in each new array, which is not I wanted. I made some confusion in the question, i think. What i require is to split a large array, say array(1000) to arrays(100), in which i will be getting first 100 points in the first column then the next 100 in the 2nd column and so on. but that is not happening with the reform command?
Did I do anything wrong?
|
|
|
Re: Split an int array into different arrays [message #83400 is a reply to message #83399] |
Mon, 04 March 2013 04:44  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> array = RandomU(seed, 100000)
> foldedArray = Rebin(array, 100, 100)
Duh! I seem to always type "Rebin" when I mean "Reform". Sorry. :-(
array = RandomU(seed, 100000)
foldedArray = Reform(array, 100, 100)
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.")
|
|
|
Re: Split an int array into different arrays [message #83401 is a reply to message #83400] |
Mon, 04 March 2013 04:29  |
Mats Löfdahl
Messages: 263 Registered: January 2012
|
Senior Member |
|
|
Den måndagen den 4:e mars 2013 kl. 13:11:57 UTC+1 skrev Krishnakumar M.A:
> Dear All,
>
> I am writing a simulation in which I have to deal with a large 1D integer array and want to split it into different arrays of same length and add them one over the other, like folding. Are there any function of idl which will do it? It will be very helpful to me, if anyone can solve this.
Sounds like you could do it by first REFORMing the large 1D array to a 2D array (the "folding") and then use TOTAL to sum over one of the dimensions.
|
|
|
Re: Split an int array into different arrays [message #83402 is a reply to message #83401] |
Mon, 04 March 2013 04:26  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Krishnakumar M.A writes:
> I am writing a simulation in which I have to deal with a large 1D integer array and want to split it into different arrays of same length and add them one over the other, like folding. Are there any function of idl which will do it? It will be very helpful to me, if anyone can solve this.
array = RandomU(seed, 100000)
foldedArray = Rebin(array, 100, 100)
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.")
|
|
|