You haven't defined sigma anywhere , I suggest you use a different name for example Sigma because there exists a function named sigma() in MATLAB.
Problem using ODE45 function
1 次查看(过去 30 天)
显示 更早的评论
function dy=pair(t,y,a,b,d,hstress,sigma,Hstar,kc,c) %function definition
dy=zeros(4,1);
dy(1)=a*sinh((b*(sigma^d)*(1-y(2)))/((1-y(3))*(1-y(4)))) ;
dy(2)=((hstress*(a*sinh(b*(sigma^d)*(1-y(2)))/(1-y(3))*(1-y(4))))/(sigma^d))*(1-y(2)/Hstar);
dy(3)=(kc/3)*power((1-y(3)),4);
dy(4)=c*y(1);
end
The above code is stored as a function file
a=0.5179;
b=1.1003E-3;
c=0.4576;
d=1;
hstress=3463.46;
Hstar=0.7846;
Kc=0.1137;
tspan=0:0.01:40;
initial_conditions=[0;0;0;0] %change the intial condition according to your values
[t,y]=ode45(@(t,y)pair(t,y,a,b,d,hstress,sigma,Hstar,Kc,c),tspan,initial_conditions) %function call
plot(t,y(:,1))
Ending with the error
Error using sigma (line 82)
Not enough input arguments.
Error in @(t,y)pair(t,y,a,b,d,hstress,sigma,Hstar,Kc,c)
I suspect I know a bit of what's going wrong.., yet I'm at loss for how to fix it.. Any help is much appreciated..
Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode45 (line 113)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in excuse (line 10)
[t,y]=ode45(@(t,y)pair(t,y,a,b,d,hstress,sigma,Hstar,Kc,c),tspan,initial_conditions) %function
call
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!