You are getting this error because you are trying to access an index outside the bounds of the array. In this case, the error is saying that the index you are trying to access must be less than or equal to 4, but you are exceeding that limit.
To avoid this error, you need to check the index before accessing the array element. You can use an if statement to check if the index is within the bounds of the array before attempting to access it. Here is an example:
main.m193 chars10 lines
In this code snippet, we check if the index is less than or equal to the number of elements in the array using the numel()
function. If the index is within bounds, we access the array element. Otherwise, we display the error message.
gistlibby LogSnag