Derivatives of Cost Function for Minimizing

조회 수: 1 (최근 30일)
ehsan
ehsan 2015년 1월 25일
편집: ehsan 2015년 1월 26일
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,

답변 (2개)

Torsten
Torsten 2015년 1월 26일
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 2015년 1월 26일
편집: ehsan 2015년 1월 26일
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) ...

카테고리

Help CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by