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!