Why "Error using odearguments“ and ”Error in ode15s“ ?
Show older comments
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 Comments
Walter Roberson
on 5 Oct 2018
We need to see your odefun and we need to know more about NN0
Walter Roberson
on 5 Oct 2018
Avoid using global.
ZHUEN RUAN
on 5 Oct 2018
Accepted Answer
More Answers (0)
Categories
Find more on Particle Swarm in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!