MATLAB [Matlab] Error running optimization.

AI Thread Summary
The discussion revolves around an error encountered while using the fminunc function in MATLAB, specifically stating that "Inputs must be a scalar and a square matrix." The user is attempting to optimize a polynomial function but is informed that the term -0.2662*x^6 leads to unbounded negative values, indicating that the polynomial does not have a minimum. The importance of using a scalar input for the function is emphasized, as using a vector or matrix will result in an error. Additionally, there is clarification that 'e' in MATLAB does not represent the exponential function and should be replaced with exp(). The conversation highlights the need to ensure proper function input and understanding of polynomial behavior in optimization.
karate
Messages
5
Reaction score
0
Error running optimization. Inputs must be a scalar and a square matri

I am trying to use fminunc using optimtool. But i got the error

Error running optimization.
Inputs must be a scalar and a square matrix.


this is the function i typed in the editor.

function F = fun(x)
F = -0.2662*x^6 + 48.19*x^5 - 3424.2*x^4 + 121708*x^3 - 2*e^6*x^2 + 2*e^7*x - 6*e^7;
end


i am not sure if this is a simple problem in matlab..i just want to optimize it using fminunc..i am new to MATLAB and there are a lot of things i do not understand.can you help me?
 
Physics news on Phys.org
Could you please post the code where you call fminunc?
 
Not sure if the error message is related to this error that you are making. You are trying to find the unconstrained minimum of a polynomial whose largest power term is -0.2662*x^6. This has no minimum. It goes down to -infinity.

If you fix that and still have a problem you should show how you are calling fminunc.
 
  • Like
Likes 1 person
sir what method did you use to find that the term -0.2662*x^6 has no minimum?
 
karate said:
sir what method did you use to find that the term -0.2662*x^6 has no minimum?

For unconstrained large values of x, x^6 is even larger. -0.2662*x^6 is unbounded negative and has no minimum.
 

Similar threads

Back
Top