Showing results for 
Search instead for 
Did you mean: 

compare and replace values in 2D-Array [later run on myRIO]

Go to solution

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;


row1[n] = row1[n];




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,


Download All
0 Kudos
Message 1 of 5

Hi sky,


autoindex over the rows of your array. Replace elements of the row as needed. Recreate your 2D array with an autoindexing output tunnel...

Best regards,

using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5

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.

0 Kudos
Message 3 of 5
Accepted by topic author SkyForCe

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.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5

Thank you very much crossrulz, that was exactly what i was looking for.

0 Kudos
Message 5 of 5