LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to output the min/max random numbers generated thus far in a for loop?

Currently, I'm using feedback nodes to compare the current random integer being produced to the previous ones. I need to display the overall min/max values that have been generated thus far. For the first iteration, the feedback node has no value and thus compares the random integer to 0, which makes it a maximum and it works. However, for the minimm part... the feedback node is comparing 0 to the first iterated random number, so 0 keeps being outputted as the random number. Is there a fix to this?

 

The problem is: Use a For Loop to generate 100 random numbers. Determine the most current maximum and minimum number as the random numbres are being generated. This is soemtimes referred to as "running" max and min. Display the numbers on the front panel in addition to the current random number.

 

I am currently using feedback nodes and the min/max function in my program

0 Kudos
Message 1 of 6
(4,626 Views)

Initialize the feedback nodes with +Inf or -Inf depending on whether you are lookin for the minimum or maximum.

0 Kudos
Message 2 of 6
(4,617 Views)

This sounds like a school assignment. Here are some hints:

 

How many values do you need to keep? How many feedback nodes do you need to store those values? What is the appropriate initial value for the minimum?

 

Lynn

0 Kudos
Message 3 of 6
(4,613 Views)

How do I do that and also how do I set infinity as a constant? Sorry, I am just learning.

0 Kudos
Message 4 of 6
(4,611 Views)

Infinity constants are on the Numeric palette.

 

Lynn

0 Kudos
Message 5 of 6
(4,603 Views)

There is a ptbypt function for that. No extra code needed.

 

(Set the sample lenght to zero and intialize if i=0, i.e. in the first iteration.)

0 Kudos
Message 6 of 6
(4,559 Views)