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

the problem: First Coloum (A) has 6635 elements, from 0.15 to 30 at a 0.0045 step, secound coloum (B) is random DBL numbers, 

 

Down sample A to 30 linear points (1-30)

 

the mean of the two Data points in B that match up to the upper and lower limit of each step need to be taken. 

 

a link below is example of the data im working with. 

 

ex: (A,189) = 0.996            (B,189) = 29.83

      (A,190) = 1.0005          (B,190) = 34.41

     

      (A,412) = 1.9995            (B,412) = 17.13

      (A,413) = 2.004             (B,413) = 14.88

 

This would be the first point in the new array (A,1) = 1   (B,1) = 32.12

and the secound point would be (A,2) = 2     (B,2) = 16.005

 

The only whole number in A is Point 30, and its value in B will be used

 

how would i sort the array to find these values, without using 60 search for elements?

and once you find that element, tell it to grab the data in the next coloum? 

 

Once that is down math nodes or Formule node will finish the vi. 

 

 

Thanks for any help

Besis

 

0 Kudos
Message 1 of 15
(5,910 Views)

Hi Btrah,

 

your problem reduces to usage of the functions Interpolate1DArray and Threshold1DArray!

 

What have you tried so far? Where are you stuck?

This forum is very good at helping to solve problems. But we aren't here to present ready-to-use solutions (aka VIs) from scratch!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 15
(5,903 Views)

I really dont have good idea how to use the interpolate 1D or the threshold, I have a attched a simple vi that i started with.  

0 Kudos
Message 3 of 15
(5,876 Views)

Hi Btrah,

 

it's quite simple:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 15
(5,872 Views)

A simple "interpolate array" is sufficient if you form an array of points first.

 

quote from the help

 

"array of numbers or points can be an array of numbers or an array of points where each point is a cluster of x and y coordinates. If this input is an array of points, the function uses the first element in the cluster (x) to obtain a fractional index by linear interpolation. The function then uses this fractional index to compute the output y value from the second cluster element (y)."

 

Don't forget to set the cluster size to 2.

 

The 2D input array contains two columns, one for x and one for y.

Message 5 of 15
(5,859 Views)

Hi Christian,

 

I know that "Interpolation using point array" method as used here some days ago

 

The OP had problems to use the basic array functions so I chose to show the traditional way (for a less steep learning curve)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 15
(5,846 Views)

interpolate.png

ok guys, thanks for all the help, Im still not getting the right data ouput, i tried many different ways and this what i have come up with. 

0 Kudos
Message 7 of 15
(5,800 Views)

Ii also tried it this way

 

interpolate3.png

0 Kudos
Message 8 of 15
(5,798 Views)

I'm sorry if I little slow on the implementation, I just started with lab view and programming is foreign to me, but I'm learning.

I also work midnights, so I'll try my best to respond to guys in the morning

Thanks for all your help, it is much appreciated. 

0 Kudos
Message 9 of 15
(5,786 Views)

Hi Btrah,

 

it would really help to have VIs (LV2014 preferred) instead of simple images. Those images are hard to debug using LabVIEW!

 

Hint1: use the AutoCleanup tool (Ctrl-U) before posting VIs/images, it really helps to avoid bended wires! 😄

Hint2: You can edit your own messages in the forum, no need to post two messages within minutes!

 

Your approach using the WHILE loop looks quite ok (I would move the IndexArray function before the loop and replace the WHILE loop by a FOR loop).

What is the problem here? Saying "not getting the right output" isn't a very helpful error description…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 15
(5,769 Views)