Derivatives of Cost Function for Minimizing

2 ビュー (過去 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 Center および File ExchangeOptimization Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by