MATLAB Answers

How can I optimize coefficients of a polynomial using fmincon?

조회 수: 7(최근 30일)
Bryant Springle
Bryant Springle 2021년 4월 28일
댓글: Bruno Luong 2021년 4월 28일
I have 3 equations that represents a curve in 3D space. These equations are
X(t) = at^5 + bt^4 + ct^3 + dt^2 + et + f
Y(t) = at^5 + bt^4 + ct^3 + dt^2 + et + f
Z(t) = at^5 + bt^4 + ct^3 + dt^2 + et + f
I have certain constraints for this problem. But figuring out how to write this into a function in Matlab is difficult. I don’t know what to do with the t^n. Since the parameters that are changing are the coefficients, how do I write this into Matlab? My cost function is J= sqrt( dxdt^2 + dydt^2 + dzdt^2) (Or at least, this is what I have been interpreting it as. The overall goal is to minimize the length of the cost function )
  댓글 수: 2
Bryant Springle
Bryant Springle 2021년 4월 28일
Sorry, I should have mentioned that teh coefficients are different for each equation. I just wanted to show that each equation is modeled by a quintic polynomial. And after viewing another answer, I am now realizing that the cost function is as integral

댓글을 달려면 로그인하십시오.

답변(1개)

Bruno Luong
Bruno Luong 2021년 4월 28일
편집: Bruno Luong 2021년 4월 28일
"The overall goal is to minimize the length of the cost function "
The overall length is
L = integral sqrt(dx/dt^2+dy/dt^2+dy/dt^2)(t) dt
t is then a integration variable to compute L that you want ti minimize.
You should program the code to compute L from coefficients by integrating on t, over whatever the interval that defines your curve.
  댓글 수: 2
Bruno Luong
Bruno Luong 2021년 4월 28일
"Would this be a valid constraint?"
Yes.
You can use Aeq/beq arguments as well since value constraints us a linear constraint wrt coefficients.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by