Re: REFORM: new subscripts must not change the number elements in array [message #90433 is a reply to message #90431] |
Mon, 02 March 2015 11:55   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
g.nacarts@gmail.com writes:
> I used the example provided by mo who said that 200*200=100*400. When a 2D array has dimensions [216,216] then 216*216=120*388.8
>
> when I tried a=reform(a,120l,388.8L,/overwrite) I got the old error
Are you familiar with "counting" numbers? 1,2,3,...
Array dimensions can only be specified with counting numbers. 388.8 is
real number, but not a counting number. You can pick any two counting
numbers to multiply together, so long as the TOTAL (also a counting
number) is the same counting number you get when you multiply the
original dimensions of the array together. Another way of saying this is
that when you reform (bend, shape, twist, etc.) an array, it can't end
up with more or less array elements then when you started.
If you DO want to end up with some other number of elements, then you
are going to have to REBIN your array, rather than REFORM it.
I say this in the most gentle way possible, but are you sure you are on
the right career path? I'm not sure math (and by extension computer
programming) is really going to be your thing. There is a way of
thinking and seeing the world that is required to write computer
programs that some people (no fault of their own!) just don't have. You
might be happier and less frustrated doing something that is more
closely related to your nature.
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.")
|
|
|