04-18-2018 05:52 AM
Hello everyone,
I am learning a Labview and have a question. I am reading a data from the file, then compare it with a random number that I generate. And if two numbers are equal, I would like to increment my variable.
I was able to do it with a shift register, but I have to wait until my for loop finishes then I can see my value.
Is there any other ways to increment a variable ? Because, in later, I would like to terminate the for loop if my variable exceeds certain value for example 3.
Here is my VI screenshot.
Solved! Go to Solution.
04-18-2018 06:03 AM
There are boolean operators in LabVIEW. Terminate your loop when you click Stop OR your value exceeds 3.
04-18-2018 06:05 AM - edited 04-18-2018 06:07 AM
04-18-2018 06:11 AM
Hi Paolo,
Thank you for your answer. Yes, I am aware of it, I don't have a problem regarding that.
My question is that, when I run my VI, my value (named as counter in my VI) shows a result when my loop iteration is completed. For example:
Data Random Value
2 3
3 4
4 4
5 1
In above case, my value (counter) should show 1 since there are only one same value pair (4,4).
I see that result when my loop finishes, not in the time that I can see they are equal.
My question is then: is there any other method (except shift register) to increment a value depends on the condition is met or not ?
I hope it is clear more.
04-18-2018 06:12 AM
Sorry, I did not read carefully your post.
shoffel is right, of course.
04-18-2018 06:15 AM
Hello,
Thank you for your answer. But I don't want to see the loop integration value.
What I want is that I want to increment a value if my data value read from the file is same as my random value.
For example:
Data Random Value
2 3
3 4
4 4
5 1
In above case, my value (counter) should show 1 since there are only one same value pair (4,4).
I see that result when my loop finishes, not in the time that I can see they are equal.
My question is then: is there any other method (except shift register) to increment a value depends on the condition is met or not ?
I hope it is clear more.
04-18-2018 06:21 AM - edited 04-18-2018 06:25 AM
04-18-2018 06:40 AM
Hi Schoffel,
Thank you for your message. Yes, your solution is valid for seeing it in the same time.
But the problem the counter value will back to zero. For example
DataValue RandomValue Counter Value
4 4 1
5 3 0
6 2 0
2 2 1
But it should be like that:
DataValue RandomValue Counter Value
4 4 1
5 3 0
6 2 0
2 2 2 (will remember the previous value and then increment)
If it was normal C# language, it would be easy. For example:
int counter; //it is my global value
for(int i = 0; i < dataValue.size; i++)
{
if(dataValue == randomValue)
{
counter++;
}else{
//do nothing
}
Thanks for your time...
04-18-2018 06:56 AM
04-18-2018 07:12 AM - edited 04-18-2018 07:13 AM
@aybarskizilay wrote:
If it was normal C# language, it would be easy. For example:
int counter; //it is my global value
for(int i = 0; i < dataValue.size; i++)
{
if(dataValue == randomValue)
{
counter++;
}else{
//do nothing
}
So you want something like this?