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 Expansion.vi expands the array and gets it ready for interpolation.
BilInterpolationofArray.vi is the current vi I am working with.
I think you should go back to the tutorials and then re-think the entire approach.
You might also want to look at some of the links listed in this old idea.
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.
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 ;))
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 ArrayExpansion.vi, 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.