fmincon: Struct contents reference from a non-struct array object for xOrigShape
이전 댓글 표시
Hi, I am trying to run some old (probably 10-15 years old) code and am running into the error:
Struct contents reference from a non-struct array object.
Error in nlconst (line 27)
xOrigShape = initVals.xOrigShape;
Error in fmincon (line 561)
nlconst(funfcn,X,l,u,full(A),B,full(Aeq),Beq,confcn,options,defaultopt,
...
Error in solve_muscle_forces (line 62)
stress =
fmincon(@Stress1,x0,[],[],A',torques',lb,ub);
Error in main_ABD_2017 (line 85)
muscle = solve_muscle_forces(angles,
torques, muscle, subject, t, str);
Based on the error, I think the problem is how the initial conditions are being passed to the functions. I've stepped through the functions. Here is line passing the arguments to the nlconst.m function:
[X,FVAL,lambda,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
nlconst(funfcn,X,l,u,full(A),B,full(Aeq),Beq,confcn,options,defaultopt, ...
verbosity,gradflag,gradconstflag,hessflag,meritFunctionType,...
f,GRAD,HESS,c,ceq,cGRAD,ceqGRAD,varargin{:});
Here is the nlconst.m function:
function [x,FVAL,lambda_out,EXITFLAG,OUTPUT,GRADIENT,HESS]= ...
nlconst(funfcn,x,lb,ub,Ain,Bin,Aeq,Beq,confcn,OPTIONS,defaultopt,...
finDiffFlags,verbosity,flags,initVals,problemInfo,optionFeedback,varargin)
It seems to me that what is being passed in the initVals position is hessflag. In other words, what is being passed is not what is expected. I end up with the following values within the function:
Aeq 7x45 double
Ain []
Beq [-23; 0.4...] (this is 7x1)
Bin []
confcn 1x1 cell
defaultopt 1x1 struct
finDiffFlags 2
flags 0
initVals 0
lb 45x1 double
optionFeedback 1x1 double
OPTIONS []
problemInfo 0
ub 45x1 double
varargin 1x6 cell
verbosity 0
x 1x45 double
The x0 that I originally define is 1x45.
I have tried running this on the oldest matlab I have easy access to (2008), and had the same error.
I do get this message at the start:
Warning: Large-scale (trust region) method does
not currently solve this type of problem,
using medium-scale (line search) instead.
> In fmincon (line 317)
In solve_muscle_forces (line 62)
In main_ABD_2017 (line 85)
But am pretty sure that I got that same message years ago when this was working. I'd appreciate any suggestions / help. Thanks.
댓글 수: 3
Star Strider
2018년 1월 28일
You probably need to bring this to the attention of MathWorks, since you could be encountering version differences. Click on Contact Us in the top right corner of this page. Include the URL of this page in your message so you do not have to repeat all of it.
Cara L Lewis
2018년 1월 28일
Star Strider
2018년 1월 28일
My pleasure!
I very much hope you manage to solve your problem.
답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!