fminbnd loop leads to same optimizer

1 次查看(过去 30 天)
I have a matrix of parameter A that is 2*2 matrix and other matrix B. The solution matrix C that is 2*1
Then I run
for i=1:1:2
C(i,1)=fminbnd(@(b) fun(A(i,1),A(i,2),b,B),0,1)
end
Then strangely, even when paramters A(1,:) and A(2,:) are very different, I got the same optimizer. For example, A is
0.870639815937867 0.845094090200317
0.748241117938819 0.400000548158531
C is
0.150263993746969
0.150256643269687
This happens multiple times. What is going on? Can it be that first run of fminbnd affects the second run of fminbnd?
  4 个评论
John D'Errico
John D'Errico 2020-8-3
The crystal ball is so foggy today. It simply will not show me the contents of your computer, to tell us what the function fun does. It just keeps on telling me that you will soon come into a large sum of money. Or maybe that means I will come into some money. Whatever. ONE of us will be getting righ soon. Maybe. Should I try my deck of MATLAB tarot cards instead? Tea leaves? :)
If you really want help, then you need to show us the function fun.
alpedhuez
alpedhuez 2020-8-3
Yes you wrote fminsearchbnd so I will appreciate if you take a look at the attached mix file. If one run this script for, let me say, 15 times, then one will encounter a case where the solutions of the optimization problems are the same even though the paramters are different. I wlll appreciate comments.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2020-8-3
编辑:Matt J 2020-8-3
In addition to hwat John said, you could plot the function to confirm whether fminbnd is giving you a good approximation of the minimizer in each case. If it is, that will tell you that it is not fminbnd's fault. The minimizer is simply not as sensitive a function of A as you had believed.
I would note that there is clearly some impact that A is having on the output. The successive C(i) that you have showed are similar, but not identical.
  15 个评论
Matt J
Matt J 2020-8-4
If the break point is not reached, it may be because an if-else-end statement sent the code along a different path...

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by