The description of what you're trying to do is somewhat difficult to
understand. I have no idea if the VI I made even gets close with
what you're trying to do but it should give you some ideas at least and
perhaps you can look at it then comment more on the specifics of your
problem.
Here are a few pointers for you though, based on your code.
- The first thing is that you have a numeric wired to the for-loop
index while the loop also has an indexing input. Keep in mind
that the indexing input will always limit the number of iterations that
the for-loop actually executes if the size of the input array is
smaller than the numeric wired to the for-loop index.
- The second thing is that you are initializing a 1-d array inside
of the for-loop and then indexing that array when it leaves the
for-loop so the output is a 2-d array. Generally speaking, it is
probably better to initialize the array only once without using the
for-loop. By dragging the input terminal down on the Initialize
Array function, you can initialize a single 2-d array to start
with. This saves time and memory as compared to
initializing a bunch of 1-d arrays and then using them to build a 2-d
array
- The third thing is that when you initialize an array, it will be
filled with all of the same value that you initialize with (part of the
problem you were having I believe). The solution is to intialize
a zero-filled array to the size that you would like, then fill sub-sets
of that array with the values you would like to place in it. A
subset might be a particular row, column, part of a row, part of a
column, or a set of cells spanning multiple rows and columns.
This is accomplished using the Replace Array Subset function.
I have modified your VI and attached it for you to look at. Like
I said, I'm not sure if it does really what you want it to, but it
should give you some ideas.
- First, the row and column dimmensions of the input array may be
obtained using the Array Size function and then indexing the array of
sizes. For a 2-d array the Array Size outputs the [Number of
Rows, Number of Columns].
- Using either the number of rows or columns as you desire, you can size your output array correctly.
- Using the Numeric input value, you can also size either the rows
or columns to be a particular dimmension, without needing a for-loop.
- Once the array is initialized, you may replace subsets of the
array with data from the input array. For my example I transposed
the columns of the input array into rows, and then replaced the rows in
the output array. Using the indexing inputs to the Replace Array
function inside of the for loop, the data could be placed anywhere
within the output array.