I have an array variable stats defined as
stats = [1,1,0];
and when running this function
function gameOver = overCheck(stats)if stats(1) == 0 gameOver = true; elseif stats(2) == 0 gameOver = true;else gameOver = false;endend
I get the error "Index exceeds the number of array elements (1)."
"Error in game2>overCheck (line 73)
elseif stats(2) == 0"
I'm wondering why it this is happening? When accessing stats(2) in other functions it works fine.
Best Answer