From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
07-28-2016 02:23 PM - edited 07-28-2016 02:26 PM
Hi all,
I'm a recent beginner to LabVIEW, so take it easy on me. I've been trying to do this for far too long and i figured I'd give the forums a shot. I'm trying to take a 2D array of strings and input them into a 1D array. Sounds simple enough, but for some reason i just can't get it. The array then feeds into a text ring. So for example, say i have an array of dimensions 4x2 [a b c d, e f g h], the output i want is a 1x2 array [abcd, efgh]. However the array could be 4x4 or 4x6, so its not fixed. The text ring lets the user select from the options (2 in this case).
Hopefully I've outlined my problem clear enough for people. Taking the strings from the 2D array and putting them in one string is as close as I've gotten to what i want. I also tried the array to spreadsheet string, but it just gave me one long string. Unless there is something blatantly obvious that i am missing, could someone give me any tips? Also, I'd just like to add that anyone telling me to go read the tutorials, source material etc. I have, trust me. Thoroughly.
I included a picture of the section of code that i am trying to get working. And yes i realize that it won't input anything to the text ring at the moment, that is currently just how i have it saved.
Solved! Go to Solution.
07-28-2016 02:31 PM
Replace the while loop with a For Loop.
Don't use Array Subset, just use auto-indexing tunnels.
Use concatenate strings on your 1-D array and you'll have a single string.
Use auto-indexing tunnels on the output and you'll have a 1-D array of those strings.
(You may need to transpose the 2-D array before feeding it into the For Loop).
07-28-2016 02:32 PM
Thank you RavensFan for saving me the trouble of posting exactly that (less the warning aobut possible transpose)
Ben
07-28-2016 04:52 PM
You talk about strings, 1D arrays, and 2D arrays and it is confusing.
For example, 4x2 are not dimensions. They probably are the sizes of a 2D array.
[a b c d, e f g h] is not an array unless you tell us what the delimiters mean. Are spaces column delimiters and commas row delimiters?
What is a 1x2 array as follows? [abcd, efgh] Is this a 1D array with two elements, where each element is a string of four characters?
The code you are showing does not help in the understanding.
Please attach a simple VI that has a typical input array containing default data and tell us what the output should look like.
07-28-2016 05:12 PM
>> ..
>> Use auto-indexing tunnels on the output and you'll have a 1-D array of those strings.
Last step is:
Use property Strings of the ring to populate the list and Value (integer up to Strigs size - 1) to select default one.
07-29-2016 09:46 AM
You are right, i was not clear enough in stating the syntax of the arrays as it has been a while since i had to do so. The array would then be (using proper syntax):
myArray = { {0,1,2,3}, {3,2,1,0} }; This array having the dimensions 4(column)x2(row). The new array would be subsequently NewArray = { {0123}, {3210}}; Hopefully, this is more clear. I did include the portion of the code that is relevant to the my question at hand.
I appreciate all the quick responses and will try them as soon as I have access. I think RavensFan's proposed solution will work, as this stuff is probably easy for you guys and you know what you are talking about.
07-29-2016 10:04 AM - edited 07-29-2016 10:05 AM
@StavA wrote:I think RavensFan's proposed solution will work, as this stuff is probably easy for you guys and you know what you are talking about.
Yes, I would use Raven's code. Here's a picture: