Finding intermediate values during minimisation

1 回表示 (過去 30 日間)
Ariwan Abdollah
Ariwan Abdollah 2021 年 10 月 13 日
コメント済み: Ariwan Abdollah 2021 年 10 月 19 日
Dear reader,
I have a minimisation problem at hand using lsqnonlin. According to the output, there are 8 iterations required to get to the final answer. Is it possible to find the values the lsqnonlin function calculates during those 8 iterations. The way I did it now is by including the line
intermediatec(:,iteration)=x0;
(where x0 is the calculated values). This however gives me much more than 8 times the intermediate x0 values.
Also, if anyone has an idea to speed up the code, that would be very helpfull too.
The full function looks like this:
global F
global intermediatec
global iteration
F = permute(squeeze(sum(IVW.*x0,2))-EVW(:,1),[2,1]) ;
F=F(:)';
iteration=iteration+1;
intermediatec(:,iteration)=x0;
kind regards,
Ariwan

採用された回答

Harikrishnan Balachandran Nair
Harikrishnan Balachandran Nair 2021 年 10 月 19 日
編集済み: Harikrishnan Balachandran Nair 2021 年 10 月 19 日
Hi Ariwan,
I understand that you are trying to solve a problem using 'lsqnonlin' function, and you want to record the intermediate 'x' values found by the function.
The same can be achieved by specifying a function handle using the 'OutputFcn' option, inside the optimization options. The optimization function would call this specified function, at the end of each iteration. You can set the options using the 'optimoptions' function. The function can be formulated in such a way that, it records the intermediate output values , in the specified location, after each iteration. You can refer to the following Documentation links to get a better idea on it
  1 件のコメント
Ariwan Abdollah
Ariwan Abdollah 2021 年 10 月 19 日
Thank you very much, I will have a look at them
Kind regards, Ariwan

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by