LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Down Sample a 2D Array and average between two numbers

Solved!
Go to solution

@Btrah79 wrote:

 

interpolate3.png


This makes no sense. That FOR loop will complete in nanoseconds, creating an array of 30 identical elements because the same calculation is simply repeated 30 times.

 

Yes, start with a few basic LabVIEW tutorials. I would use this code but you need to autoindex on a ramp of new x values, replacing the current fractional index control. Use "ramp pattern" to create the ramp. Don't wire anything to N of the FOR loop.

0 Kudos
Message 11 of 15
(1,997 Views)

I used clean up diagram before taking all screen shots?

sorry about the extra post, i will edit from now on. 

I was not getting the right data, because i didnt understand what function was doing, once i used a small test vi to figure out what

threshold and INterpolate 1D did, things started to come together. 

Data looks correct?

Thanks guys

interpolate4.png

0 Kudos
Message 12 of 15
(1,981 Views)

The compuler is pretty good at eliminating loop invariant vcode, but why would you place "index array" inside the loop? Doing that once before the loop is sufficient.

 

(Your code seems to want to average the closest value from above and below? For this you take interpolate array, round down to the nerest lower aray index, take an array subset with two elements, and take the average. No need for these silly array contants. (image A) This is not reasonable, and will not give you a real interpolated value unless the disteance of the real points from the midpoint is equal.

 

However, it seem more reasonable to get the interpolated value at the ramp location. No need to average. You get the real linearly interpolated value between the two nearest points. (image B)

 

 

 

Go with Option B!

Message 13 of 15
(1,962 Views)

I realiazed that I about 2 hours after I posted that data was just a mean between the numbers and linear piont was not, I checked my data out in excel (not correct) and and than came up with this solution - attached. 

Its not as pretty as yours, but Tonight I will try and insert Option B into it and see I can get that to work. 

But for the purpose of the Orignal post, this vi works and does what i want. 

Thanks everyone

 

interpolate5.png

0 Kudos
Message 14 of 15
(1,945 Views)
Solution
Accepted by Btrah79

My solution B above is still a few orders of magnitude better.

 

Even your new code is completely pointless. As pointed out many times, my code B will give you the exact interpolated value. That's all you need to do. Keep it simple! Have you even tried it?

 

Your last code is still Rube Goldberg! Basically you are using Interpolate/threshold to get the existing file values (within error), which is completely pointless. It also relies on two complicated array constants. Are you going to rewrite everything from scratch if the x values change? You can get these values equally easily by just rounding the fractional index up and down and then use index array (my code A, which you should not use).

 

You are still using "index array" inside the FOR loop even though the output never changes. Once is enough! That formula node is just plain silly. Also your ramp is calculated twice, once at the bottom of the bigger loop and once in blue in the smaller loop above, but using the wrong representation. Why all that duplication of effort?

 

Please remove all that silly code and implement my solution B! Listen to us!!!!

Message 15 of 15
(1,925 Views)