2 equations, 2 unknowns - fminsearch(), fminunc() applied on numerical data

조회 수: 5 (최근 30일)
I have 2 equations and , which should deliver the same result:
All of them are matrices with [m=800, n=1300]; A and B are certainly known, I tried to calculate Cx and Cy, but my problem is that the outcome is not the same - the equation is not satisfied!
I'm trying to treat Cx and Dy as unknowns and use fminsearch & fminunc by saying: to find the values for Cx and Cy which satisfy the equations. The calculation is done for every element of the matrices.
Cy_new = zeros(size(A));
Cx_new = zeros(size(A));
f2min_val = zeros(size(A));
for i=1:size(A,1)
for j=1:size(A,2)
f2min = @(C_xy) DRx(i,j) + C_xy(1) - ( DRy(i,j) + C_xy(2) );
[ C_xy, f2min_val(i,j) ] = fminunc( F2min, [-1, 0.5]); % Cx(i,j), Cy(i,j)
Cy_new(i,j) = C_xy(1); Cx_new(i,j) = C_xy(2);
end
end
The data for previously calculated Cx(i,j) and Cy(i,j) lies in a range of [-1, 0.5]
But I get the message for fminunc:
Problem appears unbounded.
fminunc stopped because the objective function value is less than
or equal to the value of the objective function limit.
<stopping criteria details>
fminunc stopped because the objective function value, -2.461927e+20, is less than
or equal to options.ObjectiveLimit = -1.000000e+20.
C_xy =
1.0e+20 *
-1.2310 1.2310
and for fminsearch
Exiting: Maximum number of function evaluations has been exceeded
- increase MaxFunEvals option.
Current function value: -111848999850590921804554051032055239655030784.000000
C_xy =
1.0e+44 *
-1.0233 0.0952
no matter what I use as starting values. Someone has an idea about what I might improve? Or is it just impossible with my data?

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2022년 6월 22일
From your description you have 800-by-1300 linear equations of the type:
a + x = b + y
and you want to solve for both x and y. Therein liest the problem. If you re-arrange the terms you will find:
x-y = b - a
and that is all you can achieve with this type of problem. You will have to accept that you can only determine the difference between x and y, and either settle for that or add more information to the problem. The results you get from the optimization-problems is due to the problem being underdetermined.
HTH
  댓글 수: 9
Philipp Bisignano
Philipp Bisignano 2022년 6월 28일
I'd have another question, so I get a result for C_xy from Matlab by doing the minimization on f2min.
By applying some boundary conditions I am also able to find a value for the constant s, by which the single terms (C_xy(1) - C_xy(2)) could be shifted.
What do I have: -
  • A possible solution out of many possible solutions for C_xy?
  • A solution for C_xy out of 2 possible ones?
Or just nonsense?
Thank you in advance!
Bjorn Gustavsson
Bjorn Gustavsson 2022년 6월 28일
To my understanding you will have one solution for C_xy(1) and C_xy(2) that both gives the same difference and the correct average value that you have determined "from elsewhere". That boundary-condition selects one pair of C_xy-values out of an otherwise infinite number of possible pairs with the same difference.

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

추가 답변 (0개)

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by