LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to combine three 1-D arrays into one 3-D array

Hey All,
 
i am not sure if i should have approached the problem differently, but basically i am moving a three axis motor. I have created three 1-d arrays (one for each axis) that hold the points to where the motor should move, but i am now wondering if it is possible to combine these three arrays into one 3d array (so each 3D 'location' only has one index number).
 
For example, if the x-axis has 5 spots, the y-axis has 4 spots, and the z-axis 3 spots, then the resultant 'cube' of locations will be 5x4x3 = 60 locations that i can select by just one index number.
 
if i was not clear on anything, let me know!
 
thanks in advance,
Marko
0 Kudos
Message 1 of 10
(3,355 Views)

When you want to make a three dimensional array, I think, you need to make sure that the number of rows and columns in each page is same (or else blank data will be added based on the biggest row / column).

This is just my thinking (pardon me if i didnt get ur intention well): You could probably arrange each motor data in a single column and put them together as a 2D array. I belive you can still achieve using one index for all motors (for row only). The column index will be depending on the motor number. Here also you need to make sure that all motor has same number of data.

Message 2 of 10
(3,349 Views)
Hey,
 
thanks for the quick reply. I understand what you are trying to say about using a single column, but my three dimensions are not going to be equal length. (You can use interleave function for this to make it a single column of xyz, xyz, xyz values.)
 
i am trying to make the 3d array to have independent length sides, so i can have more resolution in one axis than the other.
 
cheers,
Marko
0 Kudos
Message 3 of 10
(3,342 Views)

Hi Marko,

You can have a 3D array with all the 3 dimensions as unequal. It is like the shorter rows & columns will be filled with empty elements upto the maximum size of the row or column in the entire array. This has been already mentioned in the previous reply.

If this is not what you need, please tell us more of your exact requirement.

- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 4 of 10
(3,335 Views)


Deepu wrote:

When you want to make a three dimensional array, I think, you need to make sure that the number of rows and columns in each page is same (or else blank data will be added based on the biggest row / column).


Hi Marko,
 
I think what Deepu meant to say was the no. of elements in each row/column should be the same (or else blank data will be added based on the biggest row / column).
 
I hope this clears the air of doubt. Smiley Happy
- Partha ( CLD until Oct 2024 🙂 )
0 Kudos
Message 5 of 10
(3,332 Views)
I think I understand what you are trying to do but I think you acctually want a 2-D array representing the coordinate triplet. If you used a 3-D array you would still have to specify all three indicies to get your information where the indicies could already represent the position.  Each point you were tying to move to would need to have all three coordinates to signify its position.  Even if the x-axis had only 5 possible positions, the y-axis 4 positions and the z-axis only three positions, you would still need to signify all three coordinates to specify a specific position.
 
Example:
 
X-axis has the possible positions:  1, 2, 3, 4, 5
Y-axis has the possible positions:  1, 2, 3, 4
Z-axis has the possible positions:  1, 2, 3
 
To represent any point would need a X, a Y, and a Z coordinate (x, y, z)
 
Then point one could be (2, 3, 3)
point two (5, 4, 3)
and so on in any combination.
 
After you put your points together, a 2-d matrix can be easily put together representing the coordinate triplet.  From the example above the result would be a 2-D array of size 3x60.  Attached is VI that will generate this matrix and allow you to index it by one point (the row).  To access the information, enter desired point, the VI will output the coordinates.
 
Hope this helps.
Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 6 of 10
(3,328 Views)
Sorry, here is the finished one.
Quentin "Q" Alldredge

Chief LabVIEW Architect, Testeract | Owner, Q Software Innovations, LLC (QSI)
Director, GCentral | Admin, LabVIEW Wiki | Creator, The QControl Toolkit
Certified LabVIEW Architect | LabVIEW Champion | NI Alliance Partner



0 Kudos
Message 7 of 10
(3,325 Views)

Since we know the size of the array from the beginning, it would be better NOT to built an array in loops, one row at a time.

One way would be to allocate the 60x3 array feeding into the shift register and then use "replace array subset inside the inner loop and do things "in place".

Alternatively, you could also use autoindexing and reshape to the final size at the end. (see attached quick modification).

(Of course the while loop needs a wait.)

0 Kudos
Message 8 of 10
(3,313 Views)
Am I correct in assuming that you want to use integer steps in each direction, and each direction's step is a different length, and each direction has a different number of steps? (as in, X coordinates could be 1 inch steps, Y coordinates 2 inch steps, and Z coordinates 3 inch steps, so a coordinate of (1,2,3) would be 1 inch +X, 4 inches +Y, and 9 inches +Z)
 
If this is the case, it is perfectly possible.  However, your 3D array will have to have "smooth faces" to put it in visual terms, as in one row of X cannot be longer than another row of X, so the shorter will be zero padded.  If this is the case, you can simply build your 3D array such that for each combination of coordinates, you have the appropriate absolute position of your device.
0 Kudos
Message 9 of 10
(3,286 Views)
Hi
 
Jeff, you are spot on, that is pretty much exactly what i am trying to do. I am trying to move the motor to each point through a 3D space, and at the same time have more resolution / less distance moved per increment, on one axis as opposed to the other. And yes, the box would have smooth faces.
 
Q, you also got it, but i am a bit confused about the array size being 3x60. If there are 5 x 4 x 3 points in the 3D axis, which is a total of 60 points. I will take a look at the .vi you attached and hopefully that will clear it up.
 
thanks for the awesome responses!
Marko
0 Kudos
Message 10 of 10
(3,254 Views)