[Matlab] Error running optimization.

Click For Summary

Discussion Overview

The discussion revolves around an error encountered while using the MATLAB function fminunc for optimization. Participants explore the nature of the error message indicating that inputs must be a scalar and a square matrix, and they discuss the characteristics of the polynomial function being optimized.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports an error when using fminunc, stating that inputs must be a scalar and a square matrix.
  • Another participant requests the code used to call fminunc to better understand the issue.
  • It is suggested that the polynomial function defined has no minimum due to its highest degree term being -0.2662*x^6, which leads to unbounded negative values as x increases.
  • A participant questions the method used to determine that the term -0.2662*x^6 has no minimum.
  • There is a clarification that the variable 'e' in the function does not represent anything in MATLAB and that the exponential function should be expressed using exp().
  • Another participant reiterates that for large values of x, the term -0.2662*x^6 is unbounded negative and thus has no minimum.

Areas of Agreement / Disagreement

Participants express differing views on the nature of the polynomial function and its optimization properties. There is no consensus on the best approach to resolve the error, and the discussion remains unresolved regarding the optimization of the function.

Contextual Notes

Participants note that the function must be called with a scalar x, and using a vector or matrix will lead to an error. There are also unresolved assumptions regarding the behavior of the polynomial function at large values of x.

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   Reactions: 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

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 11 ·
Replies
11
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K