creating a new 2D array with two 2D arrays
Author Message
creating a new 2D array with two 2D arrays

I have two 2D arrays. I want to create a new 2D array whose zeroth
colums will be the zeroth columnn of the first 2D array, first column
will be the zeroth column of the second 2D array, second column will
be the first column of the first 2D array, thirth column will be the
first column of the second 2d array and so on. So bascially the second
2d array is inserted in to the first one like a comb and a new 2d
array having doubled number of columns is created.

Does anybody have a VI which can perform this task, which may be
called 'combing' two 2D arrays.

Thanks

Mon, 12 Dec 2005 05:41:26 GMT
creating a new 2D array with two 2D arrays
It looks like it works only if both 2D arrays has 2 columns max. But I
guess it may be modified with a for loop which returns proper insert
values to the 'insert array' when the 2d array has more number columns
(more than 2).
My 2 d arrays (both) have number of columns more than 2 for sure.

Mon, 12 Dec 2005 06:44:17 GMT
creating a new 2D array with two 2D arrays
Indeed, your vi will not work for any 2D array but only 2-column 2D
arrays. The question is how to do it efficiently, so that the Vi can
'comb' any inout 2D arrays, not arrays with a certain number of
column.
FYI, you understood well what I am trying to do, except the column
number of the 2D array. I didn't mean 2-column 2D array but any 2D
array with unspecified number of columns.
I hope I explained it better.

Mon, 12 Dec 2005 06:55:58 GMT
creating a new 2D array with two 2D arrays

Quote:

> I have two 2D arrays. I want to create a new 2D array whose zeroth
> colums will be the zeroth columnn of the first 2D array, first column
> will be the zeroth column of the second 2D array, second column will
> be the first column of the first 2D array, thirth column will be the
> first column of the second 2d array and so on. So bascially the second
> 2d array is inserted in to the first one like a comb and a new 2d
> array having doubled number of columns is created.

Assuming that the two 2D arrays are of the same size (same number of rows and
columns), you could do the following:

1. Transpose each array with the Transpose 2D Array function.
2. Wire both arrays auto-indexed into a For Loop.
3. Put a shift register onto the For Loop. Initialize the shift register with
an empty 2D array.
4. Run the left shift register terminal into a Build Array function, then the
output of the Build Array to the right shift register terminal.
5. Wire each input array auto-indexed row into the next two inputs of the
Build Array function.
6. Transpose the 2D array coming out of the For Loop at the right shift
register terminal. This transposed array is your desired result.

That's probably the most compact solution. It may or may not be the most
efficient.

Joe Czapski
Electronics Engineer
AutoMeasure
Boston, Mass.

Mon, 12 Dec 2005 07:15:17 GMT
creating a new 2D array with two 2D arrays
I just tested this and it does what you want - it may or may not be
the most time-efficient way:

ASSUMING ARRAY "A" and ARRAY "B" ARE THE SAME SIZE:

Use ARRAY SIZE on array A
Use ARRAY INDEX to get # columns (index #1) from the ARRAY SIZE output

Wire # Columns to N input of FOR loop
In FOR loop, put two INDEX ARRAY functions.
Wire array A thru loop to array input of INDEX ARRAY #1. DISABLE INDEX
at tunnel.
Wire array B thru loop to array input of INDEX ARRAY #2. DISABLE INDEX
at tunnel.

Wire I (loop counter) to INDEX #1 (the second one) of both INDEX ARRAY
functions.

The output of these is the current column of each array

Use BUILD ARRAY with three inputs:
Input 1 is from left SHIFT REG.
Input 2 is output of top Column-selector (Index Array)
Input 3 is output of bottom Column-selector (Index Array)
Output is to right SHIFT REG.

Init the SHIFT REG with an empty 2-D array.

Transpose the output SHIFT reg and there's your result.

Mon, 12 Dec 2005 09:41:20 GMT
creating a new 2D array with two 2D arrays
I had to use ARRAY SUBSET to get rid of the 2D array used as input to
the left SHIFT REGISTER because it appears in the first columns of the
final 2D array. The number of columns of the init 2D array should be
wired to INDEX #1 of the ARRAY SUBSET.

Thank you again. Very good answer.

Tue, 13 Dec 2005 00:01:42 GMT

 Page 1 of 1 [ 6 post ]

Relevant Pages