Solving system of 9 nonlinear equaitons in 16 variables
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a system of equations as follows:
I am not able to use fsolve as it says in the documentaiton that the number of variables should be as same as the number of equations. I found this on the MathWorks which says that it can be done with fsolve. Please let me know if it can be solved by any other method or by using fsolve. It will also suffice if I can know the solution exists.
I am writing the MATLAB code that I have written using fsolve.
f = @(x) [x(1)*x(9) + x(2)*x(12) + x(3)*x(15) - 13;
x(1)*x(10) + x(2)*x(13) + x(3)*x(16) - 15;
x(1)*x(11) + x(2)*x(14) - x(3)*(x(9) + x(13)) + 1;
x(4)*x(9) + x(5)*x(12) + x(6)*x(15) - 9;
x(4)*x(10) + x(5)*x(13) + x(6)*x(16) - 24;
x(4)*x(11) + x(5)*x(14) - x(6)*(x(9) + x(13));
x(7)*x(9) + x(8)*x(12) - x(15)*(x(1) + x(5)) - 7;
x(7)*x(10) + x(8)*x(13) - x(16)*(x(1) + x(5)) -2;
x(7)*x(11) + x(8)*x(14) + (x(1)+x(5))*(x(9)+x(13)) - 35];
A = zeros(1,9);
fsolve(f, A)
댓글 수: 0
채택된 답변
Torsten
2022년 11월 28일
x0 = -10*ones(16,1);
AB = [13 15 -1;9 24 0;7 2 35];
options = optimset('TolFun',1e-16,'TolX',1e-16);
x = fmincon(@(x)fun(x,AB),x0,[],[],[],[],[],[],[],options);
A = [x(1) x(2) x(3);x(4) x(5) x(6);x(7) x(8) -(x(1)+x(5))]
B = [x(9) x(10) x(11);x(12) x(13) x(14);x(15) x(16) -(x(9)+x(13))]
A*B-AB
function obj = fun(x,AB)
A = [x(1) x(2) x(3);x(4) x(5) x(6);x(7) x(8) -(x(1)+x(5))];
B = [x(9) x(10) x(11);x(12) x(13) x(14);x(15) x(16) -(x(9)+x(13))];
M = A*B - AB;
M = M(:);
obj = sum(M.^2);
end
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!