Hi,
The error is occuring because the size of the array y is 100000 but the script is trying to acess the 10001th element which does not exist.
Please refer to the following code snippet to fix the error:
i=1;
while i<numel(y) & abs(y(i))<0.05
i=i+1;
end
Documentation of 'numel' function: www.mathworks.com/help/matlab/ref/double.numel.html