i have the next code in labview which generates a random number between 0-100, i would like to do a counter which count each time that the random number is >50, but i don´t know how increase the times,i just see 1 when this happen,but if i have a new number >50 the counter is still 1, how could i increase the times that random number is >50? the case false is the same but i add +0, not +1 as true case
Solved! Go to Solution.
You have the right idea with the shift register. But the shift register needs to be on the outer while loop. Connect the wire through the case structure in the false case. You don't need the inner for loop since it only executes one time. Also it is an initialized shift register since you have the zero wired to the left side. The result will always be 0+1. (Note, there is an increment function that you could use instead of adding 1)
Some times the feedback node can give a clean implementation since you do not have to pass the wires across the entire block diagram. Also the feedback node has a conditional terminal and initializer in place.
for example if i generate 10 random numbers,and there are 6 values >50 i want to see 6 in the output, but i just see 1
i want to accumulate the true case
You can use a feedback node. That is a good way to do it but those can seem confusing to new users. They really are not complex but with inputs on the right it can seem strange.
See this example. The first loop shows what I was talking about with the shift register and case structure. You can also use the select function as shown in the second loop.
[Edit: I attached another method of incrementing using the bool to 0,1 function.
I have tried both of the recommended schematics and I still get 0 and 1. Can anyone help me out. Maybe I am using a wrong function but I am not sure why it is not working properly.
You have not tried the recommended schematics as they contain shift registers and your code does not. It is not the same code.
Read up about shift registers. Any introductory course explains them.