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 commentaires

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.
Thanks for that suggestion! I will do that.
My pleasure!
I very much hope you manage to solve your problem.

Connectez-vous pour commenter.

Réponses (1)

So it turns out that I created the version issue myself! I had a copy of fmincon in the folder with the main program. Therefore, the main program was using the local (old) fmincon function but the new nlconst.m function. I figured this out when I was creating a separate folder with only a copy of the program files... and it ran without an error. I was doing this to send those files to matlab support, so the recommendation to contact them led me to the right answer, in a roundabout way. Thanks again.

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by