12-22-2022 04:44 AM
Good morning. I'm new to this so please have mercy.
I have a matrix (n×3) and I need to separate every column with each rows into 3 different 1D arrays.
Thank you
Solved! Go to Solution.
12-22-2022 06:03 AM - edited 12-22-2022 06:10 AM
Nx3 actually sounds like.a 2 dimensional array with N rows and 3 columns.
You can wire that array into "Index Array" and expand it to 3 outputs and "Slice" the 2D array by rows or columns. Read the detailed help on index array to learn more.
If you really do have a 3D array you should post some code with default data in the array and an example of what the output should be.
12-22-2022 09:37 AM
This may be a "language" thing, but I think of an "n X 3 matrix" as a 2D arrangement of numbers having n rows and 3 columns that has certain mathematical operations (like "matrix multiplication") defined on it. Note that LabVIEW has an "Array" data type that can be of any (but rarely more than 3) dimension, and the LabVIEW Matrix was introduced more recently (a few versions ago, don't remember quite when).
Look at the functions in the Array palette, read their Help description, and you should be able to figure this out.
Bob Schor
12-22-2022 10:12 AM
@Flechery0202 wrote:
Good morning. I'm new to this so please have mercy.
I have a matrix (n×3) and I need to separate every column with each rows into 3 different 1D arrays.
Index Array with the 1st Column number wires (the others will auto-index)
12-22-2022 10:56 AM - edited 12-28-2022 10:59 AM
You have a 2D array, not a 3D array.
In LabVIEW, a "matrix" is a very special 2D array exclusively for linear algebra, so don't use that word unless it applies to your case.
Array operations are fundamental to efficient code and they are handled very elegantly in LabVIEW. You should really do some of the basic tutorials.
If you wire both indices of index array, you get a scalar element. If you wire only one index you get a row or column of a 2D array, depending on which you wire. If you want the first row, you don't need to wire any index! If you resize "index array", corresponding indices increment automatically with each output and don't need to be wired. (Similarly, if you wire only one index for a 3D array, you get one plane, etc.).
Here's a quick demo: