MATLAB: Do I get the error Array indices must be positive integers or logical values when using the sin function

MATLABsin

I tried to use this code right out of the help:
>> x=-pi:0.01:pi;
>> plot(x,sin(x)), grid on
But I get the error "Array indices must be positive integers or logical values."
I also tried:
>> z=pi/2
z =
1.5708
>> y=sin(z)
Array indices must be positive integers or logical values.

Best Answer

You named a variable sin.
Clear your workspace of this variable, e.g.: restart MATLAB, or run this command:
clear sin