04-03-2014 10:02 AM
Hello community,
I have a problem with filling an Array with String values.
What I'm trying to do, is to fill a bidimensional array with string values, but I don't find a way to make it possible.
I would like to know if there's a VI that allows you to fill the array with string values, by only indexing it with row and columns.
Something like the "Set Matrix Element" VI, but with strings (As showed on annexed file).
Thank you for your help!
04-03-2014 10:06 AM - edited 04-03-2014 10:06 AM
04-03-2014 10:21 AM - edited 04-03-2014 10:22 AM
A "matrix" has a very special narrow meaning in LabVIEW. It is only defined for numeric elements (real or complex) and mostly useful for operations in the linear algebra palette.
What you want is a 2D array. Here the element can be of any datatype, from numerics, to strings, to complicated clusters.
If you want to fill the array sequentially or randomly, you should initialize a 2D array of strings of the desired size, place it in a shift register, and then use "replace array subset" to substitute the default element value (e.g. empty string) with the desired strings.
See how far you get. Post your code if you get stuck.
04-03-2014 10:47 AM
Thank you, I partially solved the problem, but one other arised...
Following both yours suggests, I'm now able to fill the 2D Array, but the value, after being put into the 2D array, disappears just after the new one that comes, is written.
The code has been annexed.
I didn't use shift registers because I had problems with the wires configurations.
Solving the shift registers issue will probably solve the whole problem.
If you could poste a code solution, I would really appreciate it.
Thank you again!
04-03-2014 10:49 AM
Please attach your VI instead of a picture so we don't have to start from scrach.
04-03-2014 10:56 AM
Here it is. The string is written into the matrix just for a brief moment, then it disappears.
04-03-2014 11:05 AM
@Mattia_Perazzelli wrote:
Here it is. The string is written into the matrix just for a brief moment, then it disappears.
Try this.... modify as needed.
04-03-2014 11:05 AM
You'll need to initialize your array outside your for loops. Then use shift register to store the array each time though the for loop, that should populate your array with how you want.
"I won't be wronged. I won't be insulted. I won't be laid a-hand on. I don't do these things to other people, and I require the same from them." John Bernard Books
04-03-2014 11:13 AM
Oh, ok. Now it works as it should have, great!
Thank you for your help again, I hope this is gonna be helpful for others!
04-03-2014 12:37 PM
@GerdW wrote:
Hi Mattia,
to process arrays you should use array functions like ReplaceArraySubset…
I always thought that was one of the most awkwardly labeled nodes - but I can't come up with anything better.