Showing results for 
Search instead for 
Did you mean: 

Indexing through every other column


So I am trying to design a VI that takes a 2D array of any size, this array is set up to be ready for bilinear interpolation. 

To make working with the array easier, I made it a 1D array instead.


In the way I want to do it is in 3 parts:


First part: Go to every odd column (assuming index starts at 0), take the previous element and the next element, add them together and divide by 2, which will give me the new value of the odd index.


Second part: transpose the array and do previous step 


Third part: transpose array again and do previous steps again


(This image only shows first part.)




I am currently stuck on the first part. Where I am stuck is at the indexing, I cannot seem to figure out how to manipulate the iteration for it to do what I want it to do. (if that makes sense)


The two VI's I am providing are called Array Expansion and BilInterpolationofArray:


Array expands the array and gets it ready for interpolation. is the current vi I am working with.

Download All
0 Kudos
Message 1 of 16

I think you should go back to the tutorials and then re-think the entire approach.


  • Index array is resizeable.
  • Operate in place for most of the task. You could initialzize a 2D array at twice the size and just replace 1/4 of the values with data from the original array.
  • Watch out for coercion dots
  • Watch out form memory hogs. With each iteration you pad a row with as many elements as existed in the original 2D array. That's a lot of useless hot air.

You might also want to look at some of the links listed in this old idea.





LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 2 of 16

Tho I support the above reply, if you want a fast answer, make a case structure and put all your code there. Then take the iteration counter (Starts at 0) and make (i mod 2), wire that to the case structure. Make a 0 case and it should be empty, make another case and set it to default and put your code there.

Message 3 of 16

A combination of "Create Mesh" and "2D" would probably do this for you... Optionally with 2X "Create".


Not sure about the performance, it does more that you require (arbitrary X, Y coordinates). 

Message 4 of 16

Bileanear Interpolation.png

EDIT: never mind the typo in the file name...

Message 5 of 16

There are many ways to do this, of course (nearly stamp size ;). You don't even need "index array!)):




LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 6 of 16

wiebe@CARYA wrote:

... and "2D" would probably do this for you... 

Here's all we really need to use " Interpolate 2D":




LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
Message 7 of 16

Here's the code comparison for my last two examples. Haven't tested what's more efficient.

(Stock interpolate 2D (bilinear) sure has a lot of code under the hood, see for yourself! I probably would go with the triple stack ;))



LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 8 of 16


"If you weren't supposed to push it, it wouldn't be a button."
Message 9 of 16

So I understand rethinking the entire approach would be better as it is more efficient, however, I would like to be able to use my previous, which that just expands an array and gets the array ready to be interpolated. Reason being, it will help me visually see my thought process. 


From these examples, I see it expands it during the interpolation, which I agree is much more efficient and will definitely use that approach for the future. But if you already have it expanded, so in between all of your elements is a 0, would the approach still be the same? You already have an element there in that specific index, which is 0. You just want to replace that element with the average of the before and after. 

0 Kudos
Message 10 of 16