LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching data points in a cluster

Solved!
Go to solution

@altenbach

I am attaching the code I wrote, but I must say, your code is beautiful. It is exactly what I wanted. 
Can you briefly explain how this works ? 

 

Thank you ! 🙂

0 Kudos
Message 11 of 12
(729 Views)
Solution
Accepted by topic author deepen_solanki

Your code has several problems, for example equal comparisons on DBL are always problematic once you have real data. If X and Y are always integers, you should use a blue datatype.

Looking at your new code (Please give the VI a new name when attaching new and different code!!!): SInce there is an absolute upper limit on the number of iterations, you need a FOR loop, not a while loop. You can show the conditional terminal to stop early if needed. I would also rewrite the boolean logic. It would be much easier to understand using "stop when true", removing the "NOT", and adjusting the other comparisons.

 

There is also "search array", which would work perfectly using complex data. (See attached draft).

 

Now to my code: data for an xy graph is an ordered set of points (irrenspective of the exact representation (complex array, array of ponts, clust of x and y arrays, etc.) and if a cursor is locked to a plot (as in your case), only valid points can be selected. The current cursor has an x and a y, but also an index (Cursor.Index) that tells you which one of the data points is current.ly under the cursor. You can also get the same data out of a cursor move event data node (Point.Idx). (It is somewhat unfortunate that the same function is named differently between events and property nodes, but that's how it is...)

 

Note that I rearranged the data as array of scalar clusters (instead your cluster of arrays), by using a FOR loop, It is more suitable for the problem. You get all values using a single index whereas in your arrangement it is more difficult to access the values.

 

 

Message 12 of 12
(724 Views)