MATLAB Answers

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

Dursman Mchabe 님이 질문을 제출함. 9 Jan 2019
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

로그인 to comment.

태그

답변 수: 0


Translated by