Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.


Math Forum
»
Discussions
»
Software
»
comp.softsys.matlab
Notice: We are no longer accepting new posts, but the forums will continue to be readable.
Topic:
Constrained non linear system, fmincon: User supplied objective
Replies:
1
Last Post:
Feb 12, 2013 2:34 PM




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 >> Your function llgfix returns a threeelement vector instead of a >> 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 unitsphere 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 interiorpoint.
Good luck,
Alan Weiss MATLAB mathematical toolbox documentation



