Why does MATLAB say that my array index must either be a positive integer or a logical value