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

subscript indices must either be real positive integers or logicals.

Dear All,
I got this error "Subscript indices must either be real positive integers or logicals" when using Matlab. Please help me how to fix this error and regrid my data. Below show my code.
L=28.3;
B=7.08;
T=2.64;
H=3.42;
delta=0.561;
alpha=0.83;
beta=0.861;
vs=11;
om=L*(T+B/2)*(0.55+1.52*delta);
v0=vs*0.5144;
for i=1:0.1:1.5
v=v0*i;
fr=v/(9.81*L)^0.5;
Re=v*L/16.1;
CF0=10^3*0.455*(log10(Re*10^7)).^(-2.58);
Ca=0.5;
Cap=0.25;
Pdv=(L*B*T*delta*1.025)^(1/3)*vs^4.5/554.7;
% зависимость Cr от L/B
a1=L/B;
y1=[0.21 0.23 0.25 0.27 0.29 0.31 0.34 0.36 0.37];
e1=[3.5 3.75 4 4.25 4.5 4.75];
f1=[1.2 1.17 1.15 1.11 1.05 0
1.48 1.46 1.35 1.31 1.27 1.2
1.89 1.86 1.78 1.75 1.68 1.58
2.4 2.35 2.32 2.24 2.15 2.03
2.92 2.89 2.81 2.73 2.62 2.5
3.55 3.5 3.42 3.31 3.2 3.02
5 4.8 4.66 4.51 4.19 3.82
6.78 6.45 6.08 5.72 5.38 4.92
7.81 7.51 7 6.57 6.12 5.76];
c1=interp2(e1,y1,f1,a1,fr);
% зависимость Cr от B/T
a2=B/T;
y2=[0.21 0.23 0.25 0.27 0.29 0.31 0.35 0.36 0.37];
e2=[2.3 2.5 2.7 2.9 3.1];
f2=[1.38 1.34 1.29 1.21 1.1
1.57 1.55 1.52 1.49 1.45
1.98 1.97 1.94 1.89 1.79
2.47 2.45 2.41 2.34 2.25
2.98 2.97 2.94 2.89 2.79
3.58 3.55 3.51 3.46 3.32
4.28 4.23 4.16 4.08 3.99
5.48 5.41 5.34 5.21 5.04
7.18 7.06 6.95 6.86 6.74];
c2=interp2(e2,y2,f2,a2,fr);
% Зависимость Cr от beta
a3=beta;
y3=[0.21 0.23 0.25 0.27 0.29 0.31 0.34 0.36 0.37];
e3=[0.7 0.75 0.8 0.85 0.9];
f3=[1.1 1.12 1.14 1.17 1.26
1.46 1.49 1.53 1.55 1.59
1.85 1.89 1.92 1.96 2
2.16 2.27 2.35 2.42 2.58
2.8 2.84 2.87 2.97 3.38
3.19 3.29 3.48 3.52 4
4.08 4.48 4.54 4.8 5.28
5.4 5.78 5.92 6.1 6.76
6.2 6.65 6.83 7.27 7.88];
c3=interp2(e3,y3,f3,a3,fr);
% Зависимость Cr от xc
a4=0;
y4=[0.21 0.23 0.25 0.27 0.29 0.31 0.34 0.36 0.37];
e4=[-0.025 -0.02 -0.015 -0.01 -0.005 0 0.005 0.01];
f4=[1.15 1.15 1.15 1.15 1.15 1.15 1.15 1.15
1.5 1.52 1.54 1.56 1.58 1.61 1.65 1.7
1.76 1.79 1.84 1.89 1.96 2 2.05 2.1
2.05 2.11 2.2 2.36 2.48 2.58 2.68 2.78
2.57 2.67 2.77 2.87 2.99 3.08 3.19 3.38
2.95 3.08 3.31 3.46 3.62 3.8 4 4.08
3.86 4.06 4.4 4.62 4.95 5.1 5.42 5.63
5.04 5.41 5.79 6.03 6.34 6.58 6.85 7
6.1 6.47 6.75 7 7.32 7.5 7.71 7.82];
c4=interp2(e4,y4,f4,a4,fr);
% Зависимость Cr от коэффициент ф и ф0
a5=delta/beta;
y5=[0.21 0.23 0.25 0.27 0.29 0.31 0.34 0.36 0.37];
e5=[0.575 0.6 0.625 0.65 0.675];
f5=[1.04 1.1 1.25 1.47 1.74
1.47 1.56 1.73 1.9 2.06
1.83 1.94 2.04 2.37 2.55
2.05 2.3 2.65 2.98 3.3
2.55 2.9 3.45 3.98 4.77
3 3.5 4.12 5 6
4.18 4.7 5.42 6.38 7.48
5.81 6.1 6.55 7.43 8.5
6.82 7 7.56 8.35 9.28];
c5=interp2(e5,y5,f5,a5,fr);
a6=0.6;
c6=interp2(e5,y5,f5,a6,fr);
Cr=(c1.*c2.*c3.*c4.*c5)./(c6.^4);
C=CF0+Ca+Cap+Cr'
R=C.*1.025.*(v.^2)*om*0.5
% определение требуемой мощности при травлении
Rtr=R/10^3+40;
t=0.078;
w=0.078
n1=0.55;
n2=0.96;
n3=0.99;
n=n1*n2*n3*(1-t)/(1-w);
Pdtr=v*Rtr/n;
load Marineengine.mat
En = [engine.Mass;engine.Power; engine.Length ];
kp = En(2,:)./Pdtr;
np = find(kp > 1.05 & kp <1.2);
[n1,m1] = min(En(1,np));
k=engine(np(m1(1,end)));
Mdv = En(1,np(m1(1,end)));
N = En(2,np(m1(1,end)))
l = En(3,np(m1(1,end)));
kp2=N/Pdtr;
if kp2 > 1.05 & kp2 <1.2
N1=N;
break
end
end
Thank you very much,
Best regards

Best Answer

In this line:
np = find(kp > 1.05 & kp <1.2);
there are no values of kp that satisfy this condition, so np is empty.
That carries through the code until you get the error you saw.
FYI, I found this by using the debugger.