Error: Index exceeds the number of array elements (1).
Show older comments
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;
end
end
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.
Accepted Answer
More Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!