MATLAB: I got the error.”Subscript indices must either be real positive integers or logicals.” do you know why

subscript indices must either be real positive integers or logicals.

a=0;
b=0;
mass=400+30*b;
SF=3;
life=2*10^4;
length=(600+30*a)*10^-3;
mu=.2;
ys=572.3*10^6;
us=965.3*10^6;
D=[1/4 5/16 3/8 3/8 7/16 7/16 1/2 5/8 3/4 7/8 1 9/8 5/4 11/8 3/2 7/4 2 9/4 5/2 11/4 3 7/2 4 9/2 5];
pitchper=[16 14 12 10 12 10 10 8 6 6 5 5 5 4 4 4 4 3 3 3 2 2 2 2 2];
for i=1:length(D)
pitch(i)= D(i)/ pitchper(i);
end

Best Answer

You blew away the built in length() function when you did this line:
length=(600+30*a)*10^-3;
Don't do that or else you won't be able to use it in your for loop or anywhere else.