- Where you wrote y(y-1), MATLAB thinks you are calling a function, with argument y-1. Instead, you need y.*(y-1).
- All of those multiplications should be element-wise rather than matrix multiplications. If you don't know what that means, read this documentation.
- You need X and Y here, not x and y.

## 1 Comment

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/585563-why-do-i-get-this-error-message-array-indices-must-be-positive-integers-or-logical-values#comment_988148

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/585563-why-do-i-get-this-error-message-array-indices-must-be-positive-integers-or-logical-values#comment_988148

Sign in to comment.