How can I increase the array elements of the optimization variable?

조회 수: 1 (최근 30일)
Dursman Mchabe
Dursman Mchabe 2019년 1월 9일
Hi all,
I am trying to run a dynamic optimization script, and I get the error message:
Index exceeds the number of array elements (1).
Error in myModel (line 3)
dxdt(1)= -2.85.*(1/((1/k(4))+(1/k(1))).*k(3).*x(2)*x(1).*(1-(k(2).*x(1))/(1+(k(2).*x(1)))));
Error in myObj>@(t,x)myModel(t,x,k) (line 24)
[t,x] = ode15s(@(t,x)myModel(t,x,k),time,x0);
Error in odearguments (line 90)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in myObj (line 24)
[t,x] = ode15s(@(t,x)myModel(t,x,k),time,x0);
Error in fminsearch (line 200)
fv(:,1) = funfcn(x,varargin{:});
Error in DynamicOptimization (line 3)
k = fminsearch('myObj',0.05);
On another code, I used:
sol = zeros(1,numel(t));
to resolve the error of:
Index exceeds the number of array elements (1).
In the attached example, I don't know how to do it.
Please help.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Direct Search에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by