LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I randomly assign addition or subtraction in a for loop?

Solved!
Go to solution

Does anyone have any ideas for how I can randomly assign a for loop to add or subtract random numbers throughout various itterations?  My current code generates two random numbers and adds them together for a set number of itterations.  I need some random itterations to be subtraction.  Thanks in advance!  

0 Kudos
Message 1 of 3
(2,993 Views)
Solution
Accepted by topic author mcg123

Add another Random Number generator and compare the result against 0.5. Use a case structure around your addition/subtraction operator.

 

Seems like you might also want to output which operation actually got picked.

0 Kudos
Message 2 of 3
(2,980 Views)

Works great! Thank you.

0 Kudos
Message 3 of 3
(2,960 Views)