Interp1 returning NaN
Show older comments
I recently completed this code for a Prelab in one of my courses, the first time I ran the code, it worked perfectly and returned the three rpm values I was looking for, when I went back to check the numbers later that day, the code would return NaN and I can't seem to figure out why. The Target_J variable is returning as NaN and therefore causing my n value to be NaN as well.
J=0.01:0.01:1.1; size_J=size(J); loop_J=size_J(2);
size_V_a=size(V); loop_V=size_V_a(2); V_a=zeros(size_V_a(2),1);
size_n=size(V); n=zeros(size_n(2),1);
size_T=size®; loop_T=size_T(2); T=zeros(size_T(2),1);
size_target=size(V_a); loop_target=size_target(1);
for k=1:loop_target for r=1:loop_T
T(r,1)=R(1,r)/(1-t);
end
for v=1:loop_V
V_a(v,1)=(1-w)*V(v);
end
target_Thrust (k,1) = T(k,1)/(rho*(D^2)*(V_a(k,1)^2));
end
K_T = zeros(size_C_T(1),1); K_T_2 = zeros(size_J(2), size_V_a(2)); KT_J = zeros(size_J(2), size_V_a(2));
for i=1:loop_V for j=1:loop_J for m=1:loop_C_T
K_T(m,1) = C_T(m,1)*((J(1,j))^(C_T(m,2)))*...
(P_D^C_T(m,3))*(BAR^C_T(m,4)*Z^C_T(m,5));
K_T_2(j,i)=K_T_2(j,i)+K_T(m,1);
end
KT_J(j,i)=K_T_2(j,i)/(J(1,j)^2);
end
end
Target_J = zeros(1,3);
Target_J(1,1)=interp1(KT_J(:,1), J(1,:), target_Thrust(1,1)); Target_J(1,2)=interp1(KT_J(:,2), J(1,:), target_Thrust(2,1)); Target_J(1,3)=interp1(KT_J(:,3), J(1,:), target_Thrust(3,1));
n(1,1)=V_a(1,1)/(Target_J(1,1)*D) n(2,1)=V_a(2,1)/(Target_J(1,2)*D) n(3,1)=V_a(3,1)/(Target_J(1,3)*D)
Answers (0)
Categories
Find more on Interpolation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!