06-19-2023 10:28 AM
You are thinking about the problem in the "wrong way".
You have a set of "associated values": X = [1, 2, 3, 4, 5] and Y = [10, 20, 30,40, 50]. Actually, the values of Y are immaterial, as you are only interested in their "association by Array position" with the values in X.
You have a "rule" for selecting valid versions of X, and you want to apply this rule "automatically" to the "associated" values of Y.
What's an easy way to express "association" of two identically-structured 1D Arrays? Combine them into a 2D Array. XY = [[1, 2, 3, 4, 5], [10, 20, 30, 40, 50]]. Now express the XY "association" more readily. Note that you have a 2 x 5 Array, and LabVIEW "naturally" processes Arrays in Row order. But you want to process it in Column order (which I will call T(X, Y) = [[1, 10], [2, 20], [3, 30], [4, 40], [5,50]]), in which case the first "row" processed would be [1,10]. Where's X? It's the first element. Is it In Range? No, so you don't want to pass this value out of the While Loop that is "weeding out the bad elements".
Side question -- I assume you know about Indexing Tunnels, the tunnels that pop up on a For Loop when you bring an Array wire into the loop (and when you bring a wire out from the Loop). Have you ever clicked on the output Indexing Tunnel and set the "Conditional?" flag? Do you know what (wonderful) thing this does? If not, learn more about Indexing Tunnels! Needless to say, the Boolean output from In Range and Coerce belongs wired to the Indexing Tunnel.
So, if you've done things right, the output from this While Loop will be [[2, 20], [3, 30], [4,40]]. Not quite what you want, but what if you do the operation I called "T" (as in "transpose") two paragraphs ago? You'll get [[2, 3, 4], [20, 30, 40]], a 2D Array whose first Element is the Valid X you wanted and whose second element is the Valid Y. I assume you know the LabVIEW function (initials I.A.] that will get you these two 1D arrays out.
This is the solution to your post.
Bob Schor
06-20-2023 02:13 AM
Good morning ,
I will try to implement the solution you have given .
I found a solution by myself yesterday by searching the index of the element in X and redeleting the same element in the same index in Y array.
06-20-2023 08:17 AM - edited 06-20-2023 08:19 AM
@Mazespin wrote:
Good morning ,
I will try to implement the solution you have given .
I found a solution by myself yesterday by searching the index of the element in X and redeleting the same element in the same index in Y array.
Your "solution" will certainly work in this (really simple) case. But consider the following slightly more complicated example:
To solve this (type of) problem, you need to treat the "index column" as "special" and operate on it so as to effect the entire row. Ideally, this technique should work, regardless of the size(s) of the data, and with no assumptions about any column other than the Index Column.
Please test my suggestion. Among other things, it will teach you some useful ideas and techniques for working with data arrays in LabVIEW.
Bob Schor
06-20-2023 09:21 AM - edited 06-20-2023 05:57 PM
Let's not wander too far into the woods. The OP want to select a range and that's it.
Note that XY graphs "understand" quite a few datatypes, so if you would use an array of points (clusters of x and y) using "build cluster array" or (even better!) into a 1D complex array, you can use "array subset" on the graph data much more easily.
For example here's how you could interactively select the desired range using two cursors:
06-20-2023 09:25 AM
Excellent ! That's how I would do it. !
06-20-2023 03:25 PM
Oh la la Mr. Altenbaaaaach. Welcome back!
By the way @Mazespin, I think this code by Mr. Altenbach is the solution to your problem.
06-20-2023 03:49 PM
"Correct, as usual, Christian" -- I paid more attention to the "Subject" of the Post, rather than reading carefully that the OP just wanted a range ...
Bob Schor