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

4 views (last 30 days)
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?

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 22 Jun 2022
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 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 28 Jun 2022
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!