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.

Thanks for your help



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
Thanks for your answer. It works as exactly I want!
But, let me complete your answer by adding one more stage. At the end
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  
 
 [ 6 post ] 

 Relevant Pages 

1. create an array of 2D array

2. convert 2d array to 1d array without using shift registers and build array

3. 3D array to 2D concatenate array?!

4. 1D binairy array (I16) to 2D array

5. Converting Nx15 x1000 3D array to 15by1000*N 2D array

6. Change a 2D Array into a 1D Array.

7. 1d array containing means of a 2d array

8. 2D array to 1D array

9. Numeric 2d Array to 3d Array

10. How can I create 2d-Arrays??

11. how to perform operation on each element of 2d array then return 2d array?

12. Optimizing 2D tables for speed - 2D array vs. 1D array vs. vector-of-vectors

 

 
Powered by phpBB® Forum Software