This is an intermittent error. Crappy MATLAB software. Incredible.
None of the internet posts on this are correct about fixing the indexing scheme for arrays. If this were true the implication is the user code is incorrect which is not the case.
Simple tests like A=[1 2 3; 4 5 6; 7 8 9] followed by sum(A) will sometimes work and sometimes fail.
The problem is current variables in memory conflict with running code. This causes conflicts and the error message above.
To fix this; clear the workspace memory under Apps>>Clear Workspace