MATLAB: How to get solution to make this determinant zero

determinantoptimization

Example…
A=[A-x(1) B-x(2) C-x(3);D-x(4) E-x(5) F-x(6); G-x(7) H-x(8) I-x(9)]
I have to obtain x(1)…x(9) for det(A)=0

Best Answer

xvals = fminsearch(@(x) det([A-x(1) B-x(2) C-x(3);D-x(4) E-x(5) F-x(6); G-x(7) H-x(8) I-x(9)]).^2,rand(1,9)*2-1);
Note: with fminsearch the values are not constrained to your target of -1 to +1 so you might need to run the search several times
If you had a strict hierarchy x(1)<=x(2)<=x(3) and so on then this is not suitable and you should instead use fmincons with linear inequalities and upper and lower bound.