How can I optimize coefficients of a polynomial using fmincon?
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Matt J
le 28 Avr 2021
These equations are...
As you've written it, the same coefficients are used for X,Y, and Z meaning your curve has to be a straight line.
My cost function is J= sqrt( dxdt^2 + dydt^2 + dzdt^2)
This is not a scalar-valued cost function. Did you really mean,
J= sum( dxdt^2 + dydt^2 + dzdt^2)^2
Réponses (1)
Bruno Luong
le 28 Avr 2021
Modifié(e) : Bruno Luong
le 28 Avr 2021
"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 commentaires
Bruno Luong
le 28 Avr 2021
"Would this be a valid constraint?"
Yes.
You can use Aeq/beq arguments as well since value constraints us a linear constraint wrt coefficients.
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!