error solving stiff ODE system with ode15s
22 次查看(过去 30 天)
显示 更早的评论
the "Not enough input arguments" error pops up every time I run my code, the idea is that N is the spatial coordinate, and I am trying to solve the time dependency for every discrete point in space at a time, the equation for each point in space depends on the solutions for all the points before it, here is my attempt at it:
tspan=[0 logspace(1,5)];
y0=zeros(length(N));
[t,y]=ode15s(odelad,tspan,y0);
where odelad is in a separate .m file:
function dydt=odelad(t,y)
D0=5.8e-11;
IUV=1;
n=30;
sig_g=1;
alpha_G=IUV*D0;
R=3e-17;
N=logspace(17,23);
for i=1:length(N)
N_(i)=n*sum(y(1:i));
end
dydt=(R*n).*(1-2.*y)-(alpha_G/2).*f_DB96(N_)*exp(-sig_g.*N);
also f_DB96(N) is a separate function saved in the same folder, but it didn't even get that far and the erorr I keep getting:
Not enough input arguments.
Error in odelad (line 11)
N_(i)=n*sum(y(1:i));
Error in tester (line 27)
[t,y]=ode15s(odelad,tspan,y0);
help please !
0 个评论
采纳的回答
Walter Roberson
2017-8-6
Change to
[t,y]=ode15s(@odelad,tspan,y0);
2 个评论
Jan
2017-8-6
编辑:Jan
2017-8-6
@Elad Oz: If this is not clear immediately: Your code ode15s(odelad,tspan,y0) includes a call of the function odelad() without input arguments, while Walter's code provides a handle to the function as 1st input to ode15s. The error message mentions the problem clearly and you can use the debugger to find the reason by your own: Set a breakpoint in the failing line and type in the input arguments in the command line, until you understand, what's going on.
更多回答(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!