Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Topic: Constrained non linear system, fmincon: User supplied objective
Replies: 1   Last Post: Feb 12, 2013 2:34 PM

 Alan Weiss Posts: 1,422 Registered: 11/27/08
Re: Constrained non linear system, fmincon: User supplied objective
Posted: Feb 12, 2013 2:34 PM

On 2/12/2013 2:09 PM, Pl Pl wrote:
> Alan_Weiss <aweiss@mathworks.com> wrote in message
>> scalar. The objective function for fmincon must be a scalar, just as
>> the error message states.
>>
>> Alan Weiss
>> MATLAB mathematical toolbox documentation

>
> Oh of course, thank you Alan! But then, how can I solve this system
> with the unit-sphere constraint..?

Well, you could add the squares of dm. I mean,

function dm = llgfix(t,m,param)
dm = zeros(3,1);

dm(1) = f1(m(1),m(2),m(3));
dm(2) = f2(m(1),m(2),m(3));
dm(3) = f3(m(1),m(2),m(3));
% And here is the change:
dm = sum(dm.^2);
end

This will have fmincon try to minimize the sum of squares of the vector
field, which should give you the solution you seek.

If it fails, then start at a different point. And I suggest you set the
fmincon algorithm to interior-point.

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation