04-16-2025 11:22 AM
I know a 1D can't be transposed.. but it needs to be to add to the existing. as in the image.. as I am saving to txt then opeing it in excel and i need Array 1 LONG and Array 2 to be beside each other.. All data and Important data. both in the same sheet.
Solved! Go to Solution.
04-16-2025 11:40 AM - edited 04-16-2025 11:54 AM
Your VI does not contain any typical default data, so we need to guess. (It also really helps to use smaller arrays with recognizably different data instead of long arrays with very similar values to avoid confusion.)
Maybe this will help?
A few notes:
04-16-2025 12:25 PM
I'm afraid Altenbach did not answer your question. You can't do what you're trying to do. You need two output arrays. Just append your two arrays as one of your outputs (the concatenation of the truncated arr1 and arr2). Your other output output looks to be just array 2. If you need them in the same data struct, you can get something like a 2-D array of different lengths by putting each 1-D array in a cluster and making an array of those clusters.
04-16-2025 12:36 PM
If what you want to do is to add a 1D array "to the end" of a 1D array, that's called "Concatenate" Arrays. It is like "Append Array", but you right-click the function and choose "Concatenate".
Bob Schor
04-16-2025 03:17 PM
I apologize for not reading your post carefully. One thing about LabVIEW Arrays (and, as far as I know, is generally true for multi-dimensioned arrays in most Programming Languages) -- they must have "square edges", that is, for a 2D Array, all rows are the same length and all columns are the same length. It is legal to not use all the rows/columns by putting a "No data here" entry in an unused cell (for strings, this would be leaving the cell blank, for integers, it might be putting a 0 or -1 in the cell, for Floats, putting NaN in the cell). In your case, you show a picture (which at least lets me see the color of the wire, pink, suggesting you are saving Strings) which suggests a blank cell would work.
So if you have a N x 2 (N rows, 2 columns) Array and you want to "add to the end" a M x 1 set of data, you would do two steps:
I'm not attaching code nor a picture because I think the ideas of how Arrays work is more important to your getting the hang of LabVIEW (and programming), so I used "words" instead.
Bob Schor
04-16-2025 05:43 PM - edited 04-16-2025 06:00 PM
@littlesphaeroid wrote:
I'm afraid Altenbach did not answer your question.
I am "afraid" I did, because I said in the notes that ragged arrays are not supported. Since these are string arrays, padding with empty strings looks OK (numeric arrays would pad with zeroes). Excel will not care!
If we want fewer delimiters for the shorter excel rows, we could e.g. do e.g. as follows (Yes, it can be simplified in many ways!)
I was under the impression that the result should again be saved as excel, which would required quite a bit of gymnastics to process a 1D array of clusters of arrays. Sorry, I cannot look at your VI, because I only have access LabVIEW 2020 at the moment).
(there are also problems with the data itself, for example the longer arrays seems to have extra lines, judging from the overflow indicator)
04-17-2025 06:16 AM
Not sure why the picture didn't come through inline with text.. so try 2. I need to append a 1d array to a 2d array, BUT the 1D array is coming out as a column, not a row, See pic below..
As to the solution, I'm running LV 2019 and it's in 2023 so I can't open it.. Can you save as "previous version" so I can check it out
Thanks again
04-17-2025 06:34 AM - edited 04-17-2025 06:45 AM
Your "What I Want" result isn't achievable.
Each row and each column get's the same size (e.g. the 2D array is a square of data).
It would make things a lot clearer if the elements in your example where not random numbers...
04-17-2025 06:57 AM
SORRY! I didn't realize my arrays where not saved in the original post.. here are the arrays with the test data.
04-17-2025 08:03 AM
Thanks! Now I can "see what you've done" and can also "see what remains to be done".
I had not run your code, nor "made my own version to test" (because I have my own work to do), but now I understand your problem and realize you didn't "get" my original suggestion. So I'll explain how to "understand" your code, and how to "fix it" so that the "Need to append" piece can be turned into an "Appendable piece".
Your first (minor) error was to wire the size of one of the Arrays to the "N" terminal of the For Loop. You (correctly) chose to use the size of the smaller array, but if you left it unwired, you would have gotten the same "upper part" because the For Loop is made to stop when any Indexing Tunnel runs out of elements! So the Upper Part will be "correct" with N unwired.
So now you need to make a Correctly-sized 2D Array to append the "remaining elements" that are "missing" from the Upper Part. You "correctly" extract those remaining elements by using Array Subset, with Array 1 as the Input and the Index being the size of Array 2, which gives you "Need to Append". Now you have to turn this into an N x 2 array, with the first column being "Need to Append" and the second column being the Empty String constant. Simple -- wire "Need to Append" to "Array Size" (to get how many elements). Drop down an Initialize Array, with Empty String Constant as the Array Element and the Dimension Size coming from the Array Size function. Now you have two N element Arrays, one "Lower Part" (from "Need to Append") and one all Empty String Constants. Go do a Build Array. Now look at the size of that Build Array -- oops, it's 2 x N (because you "built" it from two (1 x ) N Arrays). How do you fix that? [Look through the Array functions and figure out which one turns this into an N x 2 Array.]
Now you have an N x 2 Array, the first column being all the entries in Array 1, and the second being all the entries in Array 2, with blanks after there are no more Array 2 entries.
Go fix your code.
Bob Schor