FUNCTION merge,a,b ; ;Appends two 2-D or 3-D arrays along their last dimension. ;It can be used to merge 2-D tables or 3-D movies. ;The arrays may differ only in the last dimension, their ;first dimensions must be equal. ; ;Calling: ARR3 = MERGE(ARR1,ARR2) ; ;3 April 2000, Michal on_error,1 sia=size(a) sib=size(b) if sia(0) ne sib(0) then message,'BOTH ARRAYS MUST BE 2-D OR 3-D' if sia(0) lt 2 then message,'FOR 1-D ARRAYS USE: ARR3=[ARR1,ARR2]' if sia(0) gt 3 then message,'SORRY, DOES NOT WORK FOR MORE THAN 3-D' if sia(0) eq 2 then begin ;2-D case if sia(1) ne sib(1) then message,'1st DIMENSIONS MUST BE EQUAL' ta=transpose(a) tb=transpose(b) c=transpose([ta,tb]) endif else begin ;3-D case if (sia(1) ne sib(1)) or (sia(2) ne sib(2)) then $ message,'1st AND 2nd DIMENSIONS MUST BE EQUAL' ta=transpose(a,[2,0,1]) tb=transpose(b,[2,0,1]) c=transpose([ta,tb],[1,2,0]) endelse RETURN,c END