MATLAB: Why this message error ?:Array indices must be positive integers or logical values

errorfaqMATLABscript

Hi,
When i write this little script:
———————————————————————————————————
demo matlab
t = (10:1:200)';
y = sin(2*pi*50*t)
z = y(t-10)
w = y+z
plot(t(1:50),w(1:50))
sound(w,Fs);
——————————————————————————————————-
there is a message error: message error: Array indices must be positive integers or logical values.
Howewer,when i write this:
—————————————————————————————————–
demo matlab
t = (0:0.001:100)';
y = sin(2*pi*50*t)
plot(t(1:50),y(1:50))
sound(y,Fs);
——————————————————————————————————
there is no message error.
Why?
thanks