LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert 2D array in to string (new user)

This is my 1st project. I want to compare some words in the 2D array. I read .xls file with function read 2D string. Now, I have to look for particular words in 2D atring. There are no direct function, I found to match pattern for 2D array.So, I thought to convert 2D array in to 1D array or string. How can I do that? Thank you.
0 Kudos
Message 1 of 10
(4,103 Views)

@Amy222000 wrote:
This is my 1st project. I want to compare some words in the 2D array. I read .xls file with function read 2D string. Now, I have to look for particular words in 2D atring. There are no direct function, I found to match pattern for 2D array.So, I thought to convert 2D array in to 1D array or string. How can I do that? Thank you.




Yes, your method will work. I am attaching an example VI.

There may be a more elegant way of doing this though.

Message Edited by nyc on 03-18-2005 12:32 PM

Message 2 of 10
(4,097 Views)
Thank you very much!!
0 Kudos
Message 3 of 10
(4,087 Views)
Here is a more compact solution, using the Array to spreadsheet string function...

CC
Chilly Charly    (aka CC)
Message 4 of 10
(4,080 Views)
Amy,
In general, you should NOT convert your array of strings to a string for the match pattern function, because you might get false positives. What if your first array element contains "abcd" and your second array element contains "efgh" and you would look for the presence of pattern "cdef", you would get a match even though it does not exist in any given array element.

What you need to do is place the match pattern function inside two FOR loops. (See attached example)

(Btw: CC, there is an even more "compact" way to do your solution of turning an string array into a string. It also has the advantage that it does not add spaces and newlines. See the diagram of the attached VI (LabVIEW 7.1). 🙂
0 Kudos
Message 5 of 10
(4,069 Views)
Altenbach
You are, as usual, perfectly right. I should avoid giving Doug Adams "42" type answers !
BTW, I choosed the ArrayToSpreadsheet function, instead of the concatenation trick, to avoid the issue you signaled...

CC
Chilly Charly    (aka CC)
0 Kudos
Message 6 of 10
(4,060 Views)

@chilly charly wrote:
Altenbach
BTW, I choosed the ArrayToSpreadsheet function, instead of the concatenation trick, to avoid the issue you signaled...

CC


... under the limiting assumtion that the regular expression does not contain spaces, etc., else you're back to square one. 😉

In the most general case, the strings in each array element could be random, and include separators such a space, newline, tab, or whatever.

The FOR loops are still safe under these conditions.
0 Kudos
Message 7 of 10
(4,051 Views)
After searching 2D array I got the match what I needed.Now I want to have some sequence done if I found a match. I was trying to do it in attached VI but It's not working correctly for some reason , it is time delay or index or different data type comparison. Please select XLS file in file path that I have attached. Please let me know what is wrong and what should I change?

Message Edited by Amy222000 on 03-28-2005 09:47 AM

Message Edited by Amy222000 on 03-28-2005 09:47 AM

0 Kudos
Message 8 of 10
(4,010 Views)
I had to attach XLS file in another email as it just let me attached one file at a time.

Message Edited by Amy222000 on 03-28-2005 09:47 AM

0 Kudos
Message 9 of 10
(4,006 Views)
You are doing this way too complicated. The main mistake is the fact that you autoindex your strings AND your lines in the while loop, thus you only compare line 1 with string 1, line 2 with string 2, etc. You need a match of line 3 with string #7, which of course is never tested in your code.

You also don't need to transpose your imput array, simply use the lower index to get the column. None of your wait statements are needed. This is just plain code and execution is determined by the dataflow. 🙂

Attached are a few simple modifications that should get you on the right track. I am sure it can be simplified further. (I placed the raw data into a diagram constant for simplicity, simply substitute your excel read).

Message Edited by altenbach on 03-29-2005 09:33 AM

Message 10 of 10
(3,978 Views)