[Matlab] Error running optimization.

In summary: If you had a positive quadratic term, then a minimum would exist. But a negative 6th power term is always unbounded negative.In summary, the conversation discusses an error that occurs while using the fminunc function in MATLAB. The error message states that the inputs must be a scalar and a square matrix. The conversation also includes a function that the individual is trying to optimize using fminunc, but it contains a term that has no minimum. The conversation concludes with a discussion on how to fix the error and why the term has no minimum.
  • #1
karate
5
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
  • #2
Could you please post the code where you call fminunc?
 
  • #3
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
  • #4
sir what method did you use to find that the term -0.2662*x^6 has no minimum?
 
  • #6
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.
 

Related to [Matlab] Error running optimization.

What is Matlab optimization?

Matlab optimization is a process of finding the best possible solution to a mathematical problem using the Matlab software. It involves using algorithms and mathematical functions to minimize or maximize a specific objective function.

Why am I getting an error when running optimization in Matlab?

There could be several reasons for getting an error when running optimization in Matlab. Some common reasons include incorrect syntax, improper input parameters, or a numerical issue such as division by zero. It is essential to carefully check your code and inputs to troubleshoot the error.

How do I fix an error in Matlab optimization?

To fix an error in Matlab optimization, you will need to identify the specific cause of the error. This can be done by carefully reviewing the error message and checking your code and input parameters. Once you have identified the issue, you can make the necessary corrections to your code.

Can I optimize multiple objectives in Matlab?

Yes, Matlab allows for multi-objective optimization, where more than one objective function can be minimized or maximized simultaneously. This is achieved by using multi-objective optimization techniques such as Pareto optimization or weighted sum methods.

What are some tips for optimizing efficiently in Matlab?

Some tips for optimizing efficiently in Matlab include carefully choosing the appropriate optimization algorithm for your problem, using vectorization and other optimization techniques to improve code efficiency, and performing sensitivity analyses to understand the impact of input parameters on the optimization results.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
936
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
Back
Top