Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Minimizing a function

Status
Not open for further replies.

brango

Mechanical
Feb 26, 2008
17
Hello,

If I have a function called Myfunc, and I want to minimize it.

I am trying: [X fval] = fminsearch(@Myfunc, X0)

It minimizes the result, but everytime I run it again it gives me a lower value. So im not reaching the local minimum.

I tried [X fval] = fminunc(@Myfunc, X0), but the problem is X has to be positive.

Finally I tried [X fval] = fmincon(@Myfunc, X0, [], [], [], [], LB, UB)

I set lower bound to 0 and upper bound to the desired value, but I still get errors that X is either negative or 0.

Where am I going wrong ? And is this the best way to minimize my function, or is there a better method ?

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor