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!