MATLAB: Subscript indices must either be real positive integers or logicals.

indexinglogical?loopssubscript

I got the error message after running my code (shown below). I realise that the issue is that the data I'm reading in is real numbers(decimals) and not integers. Is there any work around for matlab or way of rectifying this? The error is occuring in both the for loops. Thanks for any help provided.
f1T=transpose(f1);
f2T=transpose(f2);
i=f1T;
j=f2T;
for i=f1T
m0f1(i)= 0.5*((s1*(i+0.05))+(s1*i)*((i+0.05)-i));
mneg1f1(i)= 0.5*(s1*(i+0.05))+(s1*i)/(0.5*((i+0.05)+i))*((i+0.05)-i);
end
for j=f2T
m0f2(j)= 0.5*((s2*(j+0.1))+(s2*j)*((j+0.1)-j));
mneg1f2(j)= 0.5*(s2*(j+0.1))+(s2*j)/(0.5*((j+0.1)+j))*((j+0.1)-j);
end
m0=sum((m0f1(i))+(mof2(j)));
mneg1=sum((mneg1f1(i))+(mneg1f2(j)));
Hs=4*(SQRT(m0)); Te=mneg1/m0;

Best Answer

Subscripts must be integers greater than zero in MATLAB.
I would do something like this:
for i=1:length(f1T)
m0f1(i)= 0.5*((s1*(f1T(i)+0.05))+(s1*f1T(i))*((f1T(i)+0.05)-f1T(i)));
mneg1f1(i)= 0.5*(s1*(f1T(i)+0.05))+(s1*f1T(i))/(0.5*((f1T(i)+0.05)+f1T(i)))*((f1T(i)+0.05)-f1T(i));
end
for j=length(f2T)
m0f2(j)= 0.5*((s2*(f2T(j)+0.1))+(s2*f2T(j))*((f2T(j)+0.1)-f2T(j)));
mneg1f2(j)= 0.5*(s2*(f2T(j)+0.1))+(s2*f2T(j))/(0.5*((f2T(j)+0.1)+f2T(j)))*((f2T(j)+0.1)-f2T(j));
end
See if that works.