Why "Error using odearguments“ and ”Error in ode15s“ ?
显示 更早的评论
I am trying to solve ODE using ode15s first, when I set some parameters in the subfunction of ODE as constant, I can get the right solution. However, when I set the parameters as variable, and try to use Particle Swarm Optimization(PSO)to fit the parameters, that is to say, to optimize the parameters by fit the results of ODE to experiment datas using PSO, errors always exist like this:
if true
@(T,IN2)ZEROS(0,0) returns a vector of length 0, but the length of initial conditions vector is 30. The vector returned by @(T,IN2)ZEROS(0,0) and the initial conditions vector must have the
same number of elements.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in PSO (line 43)
[t,N]=ode15s(odefun,[0:95],NN0);
end
The changes in subfunction is like this, first constant and then change to variable.
function A=getA(ii,j,t,R,D)
%UNTITLED9 Collision efficiency
% x1 x2 x3 are fitting parameters
global x1 x2 x3
A=x1*exp(-x2*(1-ii/j).^2)/(ii*j).^(x3);
% A=0.046*exp(-0.1*(1-ii/j).^2)/(ii*j).^(0.1);
end
3 个评论
Walter Roberson
2018-10-5
We need to see your odefun and we need to know more about NN0
Walter Roberson
2018-10-5
Avoid using global.
ZHUEN RUAN
2018-10-5
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Particle Swarm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!