08-14-2019 07:11 AM
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 point
Solved! Go to Solution.
08-14-2019 07:53 AM
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
08-14-2019 10:32 AM
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?
08-14-2019 10:13 PM
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.
08-15-2019 06:42 AM - edited 08-15-2019 06:43 AM
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.

08-15-2019 07:08 AM
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.
08-15-2019 09:37 AM
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/>
08-15-2019 10:57 AM - edited 08-15-2019 12:42 PM
Some comments in Tim's code: