LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrays

Solved!
Go to solution

I have 1 array with more than 1000 element. I put this array in a chart like the image below. I want to ask if there is any way to reduce the number of elements in the array and still keep the graph shape.

For ex, 1 line only takes start point and end point2.png

0 Kudos
Message 1 of 8
(3,206 Views)

Hi Vuka,

 

You could loop through the array, calculate the slope between two consecutive points and compare it to the slope of the previous two points. If the slope is the same, that means you're on a straight line and therefore you can remove the previous element. If the slopes are different, that means you are on a curve and therefore wish to keep the element.

 

Slope is calculated as such:

slope = (y2-y1)/(x2-x1)

 

Regards,

Rokas

Message 2 of 8
(3,177 Views)

You have a graph, not a chart (big difference in LabVIEW ;))

 

There are long segments that are nearly linear, requiring few points to define the shape. Can you attach your VI with some typical data so we can see how the points are actually spaced. (Since your plot is a line, we cannot tell where the points are).

 

To "still keep the shape", you need to define the max allowable deviation for the reduced dataset. Is there noise in the xy data? Do you just want it to look approximately the same (within the plot linewidth) or are there more precise requirements?

Message 3 of 8
(3,128 Views)

I want it to look approximately the same or or more accurately is the better.

Bellow is my VI. You choose the path file 1.png and run.

Download All
0 Kudos
Message 4 of 8
(3,088 Views)
Solution
Accepted by vuka

I don't have NI Vision installed, so I got rid of that part.  And you really need to take some of the tutorials and learn about Indexing Tunnels.  They will reduce the code you currently have by about half.  To do this application, you should also read up on Shift Registers and Feedback Nodes.  You can give this code a try and mess around with the threshold until you get the results you are looking for.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 5 of 8
(3,057 Views)

Thank you for helping me. I need to learn a lot. Can you send me some documents about Shift Registers and Feedback Nodes. 

Thank you very much.

0 Kudos
Message 6 of 8
(3,045 Views)

have you checked out the links at the top of the forum page?
how about start with LabVIEW basics: <http://www.ni.com/getting-started/labview-basics/>

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 7 of 8
(3,026 Views)
Solution
Accepted by vuka

Some comments in Tim's code:

  • Using the slope is dangerous, because it is highly nonlinear and can go to infinity with pathological data.
  • I would recommend to monitor the change in angle.
  • This is especially easy if you would use a simple complex array for your XY data (see attached simple rewrite. Try a threshold of 0.2 radians).
  • To close the curve, make sure to retain the last point, even if the slope did not change much.
  • I would probably use a more complicated algorithm to e.g. look at accumulated slope/distance to the previously retained point, not the immediately previous point.  (not shown).

 

ResampleXY.png

 

Message 8 of 8
(3,001 Views)