Mindstorms EV3 - Find largest number in array

1.1k views Asked by At

Using the LabView graphical programming language that comes standard with EV3 Mindstorms, I have created an array variable that contains 6 values. I need to determine which of these six values is the largest and have the program return the index key of the largest number in the array. Any idea how this can be accomplished?

1

There are 1 answers

0
Legofan431 On

That's a pretty simple task once you know how to do it:
Create a variable, name it something like maximum. The value of the variable will be set to the value of the first index of the array.
Now, in a loop, go over each element of the array. Within each repetition, check if the value from the element is higher than the variable maximum. If it is, set the value of maximum to that of the index and save the index of the array (in another variable). If it's not, then just do nothing.

I hope you can recreate this program by my description, if not, I can make a screenshot and edit this answer.