On Monday, March 2, 2015 at 5:46:52 PM UTC+1, g.na...@gmail.com wrote:
> I didn't understand the logic of this reform(a, 100l, 200l*2l).
> If instead of A=[200,200] we have A=[216,216] and we want 120x(216x216) then this is written as reform(a, 120l, 216l*2l). Is that correct?
>
> I am trying to understand how you end up with reform(a, 100l, 200l*2l). Because when I typed this
> a = randomu(s, 216,216)
> help, reform(a, 120l, 216l*2l,/overwrite)
> I got the same error "REFORM: New subscripts must not change the number elements in A."
Look, it's getting difficult to help if the cards keep on changing.
Did you see my last message? You can do the same thing without using reform(), because I think you have not read the documentation of the reform command.
xSize = 216
ySize = 216
nImages = 120
finalArray = fltarr(xSize,ySize,nImages)
for i=0, nImages-1 do begin
;generate the array
a = randomu(s,xSize,ySize)
;put it in the final array
finalArray[0,0,i] = a
endfor
I didn't use the reform. For your information this:
finalArray[0,0,i] = a
is the same as this:
finalArray[*,*,i] = a
Just a bit faster.
As an example, try this:
test = fltarr(3,3,5)
print, test
ones = fltarr(3,3)+1.0
test[0,0,2] = ones
print, test
Test contains 5 "images" of 3x3 pixels. When you first print it, you will see 5 images with zeros in each pixel. After
test[0,0,2] = ones
you will find that the third image is filled with ones.
I think this is described here:
http://www.exelisvis.com/docs/Array_Subscript_Ranges.html
in the section "Avoid using range subscripts for assignment".
Cheers,
Helder
|