MATLAB: Index exceeds matrix dimensions problem

function variablesindexmatrix dimensions

I am geting '__Index exceeds matrix dimensions_' problem, while running the following function with input:
vanRijn(21,0.0005,0.002,2650,1000,0.2,0.9)
Where can my mistake be?
function [m_b]=vanRijn(T,d_50,d_90,den_s,den_w,R,v_m)
%%step1
nu=0.00000178/(1+0.0337*T+0.000221*T^2);
d_g=d_50*(9.81*(den_s-den_w)/den_w/nu^2)^(1/3);
%%step 2 Shields parameter
if d_g<=4
theta_cr=0.24*d_g^(-1);
elseif d_g>4 && d_g<=10
theta_cr=0.14*d_g^(-0.64);
elseif d_g>10 && d_g<=20
theta_cr=0.04*d_g^(-0.10);
elseif d_g>20 && d_g<=150
theta_cr=0.013*d_g^0.29;
else
theta_cr=0.055;
end
v_cr=sqrt(theta_cr*(den_s-den_w)/den_w*9.81*d_50);
%%step 3 chezy coeficient
C_prime=18*log10(12*R/3/d_90);
%%step 4
v_0_ef=sqrt(9.81)*v_m/C_prime;
%%Step 5
transp=(v_0_ef^2-v_cr^2)/v_cr^2;
%%step 6
m_b=0.053*(transp^2.1)/(d_g^0.3)*den_s*sqrt(9.81*(den_s-den_w)/den_w)*d_50^1.5;

Best Answer

The shown code runs fine on my computer and replies 0.68863.
Did you edit the code and forgot to save? Do you have mutliple files with this name in the PATH?
which vanRijn -all
Did you create a function file called "sqrt.m" or "log10.m"? Anyhow, using the debugger with the command Fangjun has suggested already, is the best idea. Usually the debugger is even more efficient than this forum.
Just a remark:
if d_g<=4
theta_cr=0.24*d_g^(-1);
% elseif d_g>4 && d_g<=10
elseif d_g<=10 % Better! d_g <= 4 is excluded already