LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

50 max values

Hi all,

 

I am new to LabView and have a question most of you may find simple. I am trying to collect torque signals from an isokinetic dynamometer and need to collect the 50 highest (max) values in the order in which they occur. I know how to find the maximum and minimum values, but need the highest 50. Thank you so much.

0 Kudos
Message 1 of 6
(2,873 Views)

Intialize an array of 50 numbers of -Inf before your while loop.  Take a value.  Find the minimum of the array, if the new value is greater than that, then delete that minimum value from the array and build the new value onto the end of the array.  If the new value is less than the minimum of the array, then it is not one of the 50 largest, so just pass through the array untouched.

 

Repeat forever.

0 Kudos
Message 2 of 6
(2,866 Views)
Depending on the size of your array another method you could use would be to make a copy of the array, sort it from largest to smallest and grab the 50th element of the array. Next, initialize an array of size 50. Now run your original data into a FOR and use autoindexing to iterate over your array. If the value is equal to or larger than the minimum value you determined replace the nth value of your max array. You will need to keep track of the index that you will need to replace using a shift register. You can stop the loop once you have processed your entire array or you find the first 50 maximum values. This seems a bit complicated but you did say that you wanted your max array to maintain the order of the values from your original data. I am not sure that Ravens approach would do that for you.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 3 of 6
(2,850 Views)

Mine would maintain the order.  I said the new value would be built onto the end of the array.  The minimum value that would be the old 50th maximum would get deleted from the array.  So any values after that would get moved up.  You'd just have to use the index from the function to find the minimum in the array when you do the Delete from Array subset.

 

One question I would have of the OP that would affect the algorithm used is whether these values need to be acquired and processed one at a time, or if the analysis of the 50 biggest can occur after all data samples have been collected.  My method would fit the former, your method would fit the latter.

0 Kudos
Message 4 of 6
(2,843 Views)
Actually I believe I was a bit unclear about what I need. I am new to this stuff, so let me explain in exercise terms what my research participants are doing and maybe that'll help. The subjects will perform 50 consecutive repetitions on the dynamometer. I need the highest torque value from each of these 50 single repetitions. Once I have the 50 values I will run other exercise-related statistics on them (mean torque for the 50 repetitions, % decline from the first to the last repetition, etc.). I have attached my program thus far. The initial information in my For Loop is calibration data for the dynamometer. Thanks again.
0 Kudos
Message 5 of 6
(2,835 Views)
Message Edited by Ravens Fan on 03-17-2010 10:50 PM
0 Kudos
Message 6 of 6
(2,831 Views)