Derivatives of Cost Function for Minimizing

1 vue (au cours des 30 derniers jours)
ehsan
ehsan le 25 Jan 2015
Modifié(e) : ehsan le 26 Jan 2015
Hi, I have this Cost Function H = 1/(deltaX)^2 [(A2 - A1)^2 + (A3 - A2)^2 + (A4 - A3)^2] I'd like to minimize this cost function by forming the derivatives of our function's variable. So here we have:
dH/dA1 = 2/(deltaX)^2 * ( - A2 + A1)
dH/dA2 = 2/(deltaX)^2 * (-A1 + 2A2 - A3)
dH/dA3 = 2/(deltaX)^2 * (-A2 + 2A3 - A4)
dH/dA4 = 2/(deltaX)^2 * (A4 - A3)
I need to write MATLAB code for above example. I thank you If someone help me in this regards,
Best Regards,

Réponses (2)

Torsten
Torsten le 26 Jan 2015
If you take a look at your cost function, I can tell you without taking any derivatives that all vectors (A1,A2,A3,A4)=(c,c,c,c) for c in IR minimize your cost function.
Best wishes
Torsten.

ehsan
ehsan le 26 Jan 2015
Modifié(e) : ehsan le 26 Jan 2015
Thanks Torsten, Fortunately I found where was the problem. I didn't take into account the power of 2 (^2) in my equation for the calculation. so here with this simple code we can get:
dH/dA1 = diff (H,A1) ...

Catégories

En savoir plus sur Get Started with Optimization Toolbox 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!

Translated by