필터 지우기
필터 지우기

fminbnd loop leads to same optimizer

조회 수: 1 (최근 30일)
alpedhuez
alpedhuez 2020년 8월 3일
댓글: alpedhuez 2020년 8월 4일
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...
alpedhuez
alpedhuez 2020년 8월 4일
Let me work on it.

댓글을 달려면 로그인하십시오.

추가 답변 (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