ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array problem

Hi,

I have a 3d array where each page has 2d arrays as follows
1 1
2 1
5 1
4 1

0 1
2 1
3 1
7 1
9 1
...

I want to combine these arrays together into one large array so that it looks like
0 1
1 1
2 2
3 1
4 1
5 1
6 0
7 1
8 0
9 1
and so forth.

The basic problem is to turn this 3d array into a 2d array. I want to keep the row elements of the 2d array intact except for adding a 0 where there is no 1 found, but I want to add up all the 1's where they are repeated on each page.

I had thought about some ideas of how to do this, but would like to get some suggestions from others. Please post responses in labview 7.1 if that is possible. I can also open in labview 8 but I have to go to a different computer which is more cumbersome.

Thank you


0 Kudos
Message 1 of 2
(2,631 Views)
At first it wasn't clear what you were trying to and I had to look at your arrays and read your description several time before I got it. There's also something odd in the sense you said that you had a 3D array, but in your example the first 2D array has one less row than the second example. In a 3D array each page would have the same number of rows for the 2D array. That aside, there's really three different things you're trying to do here:

  1. Go from a 3D array to a 2D array: Use the "Reshape Array" function for this. You basically just need to set the first dimension of the 2D array to be the multiplication of the first two indices of the array dimension sizes of your 2D array, as shown in this pic:



  2. Sort 2D array. There is no built-in "Sort 2D Array" function. You can write it yourself, or just use the one from the OpenG library.
  3. Insert "missing" rows. For this you need to write your own routine that's basically just a for loop and checks each row to see if the value in the first column is the next number in the sequence. If not, just use an "Insert Into Array" function to insert your row. Your 2D array would be updated via a shift register. It seems that, based on your example, the numbers are the sequential integers, so you can just check against the loop's "i" terminal.

Message Edited by smercurio_fc on 10-23-2006 01:05 PM

Message 2 of 2
(2,618 Views)