Sorry I should have made it more clear. a and b are vectors of equal lengths but not for each iteration i.e for i=1 length(a)=399 length(b)=399 but for i=2 length(a)=length(b)=421 etc Thanks again Ben! MA