07-02-2020 08:17 PM - edited 07-02-2020 08:22 PM
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.
07-02-2020 09:07 PM - edited 07-02-2020 09:09 PM
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.
07-03-2020 03:49 AM
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.
07-03-2020 04:17 AM
A combination of "Create Mesh Grid.vi" and "2D Interpolate.vi" would probably do this for you... Optionally with 2X "Create Ramp.vi".
Not sure about the performance, it does more that you require (arbitrary X, Y coordinates).
07-03-2020 04:30 AM - edited 07-03-2020 04:32 AM
07-03-2020 10:20 AM - edited 07-03-2020 11:12 AM
There are many ways to do this, of course (nearly stamp size ;). You don't even need "index array!)):
07-03-2020 10:45 AM
wiebe@CARYA wrote:
... and "2D Interpolate.vi" would probably do this for you...
Here's all we really need to use " Interpolate 2D":
07-03-2020 11:02 AM - edited 07-03-2020 11:10 AM
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 ;))
07-03-2020 02:44 PM
07-03-2020 07:01 PM
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.