Derivatives of Cost Function for Minimizing

1 visualización (últimos 30 días)
ehsan
ehsan el 25 de En. de 2015
Editada: ehsan el 26 de En. de 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,

Respuestas (2)

Torsten
Torsten el 26 de En. de 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 el 26 de En. de 2015
Editada: ehsan el 26 de En. de 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) ...

Categorías

Más información sobre Get Started with Optimization Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by