MATLAB: Error with function and script

attempted to accesserrorindex must be a positive integer or logical.MATLABode15sscript

Below is the function
function yprime = temp1t(t,y)
d=20*10^-6;
pg=0.1624;
Vol=(pi/6)*d^3;
As=(pi/4)*d^2;
Ad=(pi*d^2);
g=9.81;
pm=3545;
vgo=1188;
e=0.035;
s=5.671*10^-8;
Kg=.15015;
Cpg=5278;
ug=198.6*10^-6;
Tgas=300;
yprime(1,1)=y(2);
yprime(2,1)=(Vol*(pm-pg)*g-(0.5*pg*As)*(637*abs((vgo*exp(-y(1)/2)-y(2)))^-0.77)*(abs(y(2)-(vgo*exp(-y(1)/2))))*(y(2)-vgo*exp(-y(1)/2)))/(pm*Vol);
yprime(3,1)=((((Kg/d)*( 2+(0.6*(pg^(1/2))*(d^(1/2))*((abs((vgo*(exp(-y(1)/2)))-(y(2))))^(1/2))*(Cpg^(1/3))*(ug^(-1/6))*(Kg^(-1/3))))))*(Ad*(y(3)-Tgas^4))-(Ad*e*s((y(3)^4)-Tgas^4)))/(Vol*pm*(21.8+.009*y(3)));
Below is the script
y0(1,1)=0;
y0(2,1)=0;
y0(3,1)=1373;
tspan=[0,.002];
[t,y]=ode15s('temp1t',tspan,y0);
figure(3)
plot(t,y(:,3))
title('Droplet Temperature Vs. flight Time')
xlabel('Flight Time (ms)')
ylabel('Temperature (K)')
Goal
I am trying to get a plot of temperature versus time, utilizing all the given inputs and given equations.
Error
Attempted to access s(-2.03164e+09); index must be a positive integer or logical.
Error in temp1t (line 21)
yprime(3,1)=((((Kg/d)*(
2+(0.6*(pg^(1/2))*(d^(1/2))*((abs((vgo*(exp(-y(1)/2)))-(y(2))))^(1/2))*(Cpg^(1/3))*(ug^(-1/6))*(Kg^(-1/3))))))*(Ad*(y(3)-Tgas^4))-(Ad*e*s((y(3)^4)-Tgas^4)))/(Vol*pm*(21.8+.009*y(3)));
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 148)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in temp_modelt (line 6)
[t,y]=ode15s('temp1t',tspan,y0);

Best Answer

Your function includes the subexpression
s((y(3)^4)-Tgas^4)
that is a request to index s at location (y(3)^4)-Tgas^4
Remember, there is no implicit multiplication in MATLAB.
Related Question