24 Write a function that computes the next LED to control
In MATLAB edit the function named nextIndex that computes the index of the next LED to control. The function should satisfy all of the following requirements:
- it should return a value named
next - it should be named
nextIndex - it should have one input variable called
currthat is equal to the index of the LED that was most recently turned on or off - it should return
nextthe index of the next LED to blink given the indexcurrof the LED that was most recently turned on or off
For example:
nextIndex(0)should return1nextIndex(1)should return2nextIndex(2)should return3nextIndex(3)should return0nextIndex(4)should return1nextIndex(5)should return2nextIndex(6)should return3nextIndex(7)should return0- and so on
Your function should not use any if statements or switch statements; instead, you should simply wrap the value curr + 1 to the range 0 to 3 using mod or rem.
Test your function in the MATLAB Command Window to ensure that your function returns the expected values shown above.