An index can be any kind of expression, but the value of the expression has to be a positive integer, and it has to be less than or equal to the length of the vector. If it’s zero or negative, you’ll get an error:
>> Y(0) Array indices must be positive integers or logical values.
If it’s not an integer, you get an error:
>> Y(1.5) Array indices must be positive integers or logical values.
If the index is too big, you also get an error:
>> Y(5) Index exceeds the number of array elements (4).
The error messages use the word array rather than matrix, but they mean the same thing, at least for now.