LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Store data if the condition is true

I want to create a simple VI application.  The VI will read in 2 1-D array & compare the data between these 2 arrays.  I want to store the data as well as the index when the condition is true.  Since the output of the comparision function is boolean, how can I retrieve the data when the condition is true?  My model could be messy since I am still debugging.

 

Thanks in advnace

Download All
0 Kudos
Message 1 of 15
(4,336 Views)

How's this?

 

Depending on the structure of your input file, you might want to transpose the array before the loop.

0 Kudos
Message 2 of 15
(4,320 Views)

The "Select" function will return both data depedning on the comparasion result.  I only want to store the data when the condition is true.  I am still debugging, thanks.

0 Kudos
Message 3 of 15
(4,280 Views)

If you (and LandBelanky) are not familiar with the simple case statement, please see LabVIEW 101 tutorial.

0 Kudos
Message 4 of 15
(4,274 Views)

Land Belenky is very familiar with how case structures work, Beotch.

 

If anyone had bothered to look at the code I wrote, they would see how it works.

 

The select function is triggered by the condition.  If the condition is false, it returns only the previous results and does not include the current values.  In that way, it does not store the data when the condition it false.  It ignores it and goes on to the next iteration.

 

If the select function is true, it adds the current value to the previous and returns both.

 

Have you tried running the VI I wrote?  I tested it and it appears to do exactly what you requested.  I tested it with the following input array:

 

0,0

1,1

2,2

3,3

0,1

0,2

0,3

0,4

1,1

 

You will notice that the 0th, 1st, 2nd, 3rd and 8th rows have a match.  Therefore these indexes and values are recorded in the output.  The 4th, 5th, 6th and 7th rows do not have matches.  Therefore, neither their indexes nor their matches are reported in the output.

 

It produces the following output:

 

0,0

1,1

2,2

3,3

8,1

 

The first colum is the index of positive matches.  The second column is the values.

 

I really think that's what you requested.  If you're still having a problem, please be more clear about what you're looking for.

 

 

 

0 Kudos
Message 5 of 15
(4,267 Views)

@LandBelenky wrote:
Land Belenky is very familiar with how case structures work, Beotch.

 



Unless you are good friends with Dennis, I would refrain from this kind of comment in a post.

 

 

Save this kind of language for Facebook and Twitter...


Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T
If you don't hate time zones, you're not a real programmer.

"You are what you don't automate"
Inplaceness is synonymous with insidiousness

0 Kudos
Message 6 of 15
(4,260 Views)

The question was how to store data when the condition was true, not to always store data.

0 Kudos
Message 7 of 15
(4,256 Views)

I think it would help if he could be more specific about what "the condition" is.

 

My VI does a pair-wise comparison of the elements in the two columns.  If (and only if) the values of the two elements are identical, it considers the condition to be true for that pair and therefore saves that data in the final result.  That seems to be what he was attempting to do in his original VI.

 

From the phrasing of the original question, it's not really clear what he considers "the condition" to be.  Perhaps he's trying to compare the arrays in aggregate and then save the data only if ALL elements match.  In that case, the solution is trivial.

 

The VI I presented works as described.  If anyone wants it to work differently, they'll need to describe the desired outcome better.

 

If anyone else would like to offer a solution, that would also be allowed.

0 Kudos
Message 8 of 15
(4,250 Views)

I will resume to work on my application on Monday.  Please keep sending me the solution if any.  Thanks.

0 Kudos
Message 9 of 15
(4,248 Views)

Your model works with 2 columns of spreadsheet of data.  I was trying to read a one-column of spreadsheet data &  to check if there are 2 consecutive rows of identical value of data.  The attached file was created to test the application & the output is incorrect.  The identical data are at row 26 & 27 (value is 25).

Download All
0 Kudos
Message 10 of 15
(4,212 Views)