01-02-2019 07:09 AM
Hey guys,
I am desperately trying to find out how to search and replace specific numbers in my 2D-Array.
So, the program should do the following with each row.
if (row1[n] > 4 && row2[n] != -1)
row1[n] = -1;
else
row1[n] = row1[n];
AND
if (row1[n] > 4 && row2[n] = -1
{
row2[n] = row1[n] - 5;
row1[n] = -1;
}
If the first element of row1 is greater than 4 and also the first element of row2 isn't equal to -1, then set the first element of row1 to -1.
Also if the first element of row1 is greter than 4 and the first element of row2 is equal to -1, then set the first element of row2 to the number in the first element of row1 -5;
and set the first element of row1 to -1.
As you might see my experience with LabVIEW isn't all that great. My program does that only for the first element.
How do I get it to go though the whole array one by one and is there a way to talk to the array row-whise and not index-whise?
I attached additional information and a VI snipped.
Hope you can help me with the given information. If someting is unclear feel free to ask.
All this is going to be part of a machine that plays the guitar.
Thanks in advance,
Sky
Solved! Go to Solution.
01-02-2019 07:19 AM
01-02-2019 07:27 AM - edited 01-02-2019 07:30 AM
Thank GerdW, but I don't quite get it.
So, what exactly do you mean by autoindex over the rows. How do I do that?
My input and output are autoindexing.
I can't just connect the array in autoindex mode to the index input of the "Index Array" function
And for some reason my Array doesn't have a x and y value, but just one index that goes row-whise.
Sorry, I am just starting out in LabVIEW.
01-02-2019 08:34 AM - edited 01-02-2019 08:35 AM
I think what you really want is to autoindex on the Column. To do that, you need to use Transpose 2D Array and then autoindex on the resulting array. Inside, you want another FOR loop to iterate over each row with the next row in order to do the comparison and replace as necessary.
01-02-2019 09:12 AM
Thank you very much crossrulz, that was exactly what i was looking for.