我正在尝试使用“sde_euler”求解两个随机微分方程组。这是我的代码:
function y = stoch_Fx_model(t0,tf,F0,x0)
r=1;
sig=1;
lambda=1;
h=1;
S=1;
f= @(t,Y)[r.*Y(1).*(1-Y(1)) -h.*Y(1).*(1-Y(2))./(Y(1)+S);
lambda.*Y(2).*(1-Y(2)).*(1+sig.*(2.*Y(2)-2.*Y(1)-1))];
g=@(t,Y)[0.5;0.6];
dt=0.001;
t=t0:dt:tf;
Y0=[F0;x0];
opts = sdeset('ConstGFUN','yes','NonNegative','yes');
y = sde_euler(f,g,t,Y0,opts);
y = min(y,1);
plot(t,y(:,1))
end
在指定t0,tf,x0,F0的值后运行代码,我遇到以下错误:
Error using sdearguments (line 22)
Input vector TSPAN must have length >= 2. See SDE_EULER.
Error in sde_euler (line 130)
[N,D,tspan,tdir,lt,y0,fout,gout,dgout,dg,h,ConstStep,dataType,NonNegative,...
Error in stoch_Fx_model (line 19)
y = sde_euler(f,g,t,Y0,opts);
我不明白我的错误。我的TSPAN长度大于2。以下是工具箱的来源:
https://github.com/horchler/SDETools/blob/master/SDETools/sde_euler.m
请帮忙吗? 谢谢!