フィルターのクリア

fsolve does not work when combining functions

1 回表示 (過去 30 日間)
pemfir
pemfir 2012 年 9 月 28 日
i have the following functions:
f1 = @(k1)108.4*k1
f2 = @(k2)108.4*k2
f3 = @(k3)108.4*k3
f1,f2,f3 are automatically generated, and can be very different. i would like to have a unifying function
f = f1 + f2 + f3
and i want to call f in solvers such as fsolve or fmincon. these are some suggestions i recieved:
sumf = @(k1,k2,k3) f1(k1)+f2(k2)+f3(k3);
sumf( 1, 2, 3 )
ans =
650.4000
or
sumf = @(k) f1(k)+f2(k)+f3(k);
sumf( 2 )
ans =
650.4000
but fsolve does not accept
sumf = @(k1,k2,k3) f1(k1)+f2(k2)+f3(k3);
fsolve takes the function in the form
sumf = @(k) f1(k(1))+f2(k(2))+f3(k(3));
is there any way to combine them so that they can be put into fsolve ?

採用された回答

Matt Fig
Matt Fig 2012 年 9 月 28 日
編集済み: Matt Fig 2012 年 9 月 28 日
Why won't this work?
sumf = @(k) f1(k(1))+f2(k(2))+f3(k(3));
sumf([1 2 3].')
fsolve(sumf,[3;1;2])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGenetic Algorithm についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by