Minimisation of function that contains vectors as constants

1 回表示 (過去 30 日間)
abaza
abaza 2017 年 4 月 26 日
編集済み: Matt J 2017 年 4 月 26 日
I am very new in minimization via Matlab! I would like your advice about how to minimise a specific function to be equal to the values of a vector. My function is:
objfun = @(x)(((x(1) .* exp((x(2) .* k + imag((((x(3) .* F)) .* k) + x(4)))))) == KK)
[x,Fval] = fminsearch(objfun,[1,2,2,40],options);
Namely I would like to minimise the objfun to be equal to KK, where KK is a vector of size 130x1.
But also, F and k are vectors of size 130x1.
As I said I am very new at minimisation by Matlab and I do not know how to solve and express this!!! Should it be in a loop? When I am trying a loop (e.g. for i=1:130), I get every time the initial values as result! I would like to thank you in advance for any help and I am very sorry if this looks very silly to you!

採用された回答

Stephen23
Stephen23 2017 年 4 月 26 日
編集済み: Stephen23 2017 年 4 月 26 日
When you calculate the equivalence like this
(...)==KK
then the output can have only two possible values: true or false. This is not enough information for an optimization routine, which needs to be able to figure out how far away from the solution it is, and in what direction it should change the x values. To do this you need to give the difference, because the difference tells the optimization routine how different the current function and KK values are. Then it will adjust the x values to reduce this difference.
objfun = @(x)(x(1) .* exp(x(2) .* k + imag(((x(3) .* F) .* k) + x(4)))) - KK;
[x,Fval] = fminsearch(objfun,[1,2,2,40],options);
  1 件のコメント
abaza
abaza 2017 年 4 月 26 日
Thank you for your quick reply!!! Should i use a loop?

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2017 年 4 月 26 日
編集済み: Matt J 2017 年 4 月 26 日
I suspect that this is not an optimization problem at all. I suspect that what you are really try to get is
result = find( (((x(1) .* exp((x(2) .* k + ...
imag((((x(3) .* F)) .* k) + x(4)))))) == KK) , 1);

カテゴリ

Help Center および File ExchangeGet 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