About this ode function

1 次查看(过去 30 天)
qingze
qingze 2014-10-15
评论: qingze 2014-10-15
I want to calculate this ode function with initial value y(4)=-3. But it shows not enough input error at line
dy= (K1*t+K2*y-az)/(K3*t+K4*y+kz); Can someone help please? Thanks!
function dy = coexistline(t,y)
K1 =4.9493e-04;
K2 =-1.0058e-04;
K3 =1.0058e-04;
K4 =0.0081;
az = 0.088235;
kz = -1.65625;
%dy = zeros(1,1); % a column vector
dy= (K1*t+K2*y-az)/(K3*t+K4*y+kz);
options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-5]);
[T,Y] = ode45(@coexistline,[-10 10],-3,options);
plot(T,Y,'-o')

回答(1 个)

Stephen Carter
Stephen Carter 2014-10-15
I think 'AbsTol',[1e-4 1e-4 1e-5] is your problem. Since your solution has only one component for each timestep, I believe your tolerance also needs to be scalar. Try 'AbsTol',1e-4 instead.
And... looking further at what you said... you say you want initial value y(4)=-3. Do you mean you want y to equal -3 at t=4? If so, then your input is wrong. You seem to put y as -3 at time -10.

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by