MATLAB: Subscript Error Plz help

MATLABsubscript indices

Pk is a 1*5 , and LandaMean is 1*37 matrice
b=1
m=6
for k=1:(n-(2*b)-m+1);
Pk = LandaMean(k+1:k+m-1);
for i=k+1:k+m-1
if sum(abs(Pk(i)-LandaMean(k)))<= (2*s);
LandaU =(1/m)*sum(LandaMean(k:k+m-1));
break
else
end
end
end
But I get this error:
Subscript indices must either be real positive integers or logicals.
Error in TailDep (line 50)
if sum(abs(Pk(i)-LandaMean(k)))<= (2*s);
Thank you

Best Answer

Just look at line 50 and what vectors are there. Probably there is something like
vector(negative_number)
So check why the index is negative...